private function buildNode($node, $references, $tree, $maxLevel)
    {
        if ($node->getId() == $this->getCurrentCategoryId()) {
            $node->setCurrent(true);
            $this->currentLeaf = $node;
        }

        $references[$node->getId()] = $node;

        if ($node->getParentId() == $this->rootId) {
            $this->buildRootNode($node, $tree, 1);
        } else {
            $this->buildChildNode($node, $references, $maxLevel);
        }
    }