private function buildTree($dataSet, $maxLevel = 0)
    {
        $tree = new \ArrayIterator();
        $references = new \ArrayIterator();

        /** @var DocumentIterator $dataSet */
        foreach ($dataSet as $node) {
            if ($node->isActive()) {
                $this->buildNode($node, $references, $tree, $maxLevel);
            }
        }

        $this->expandNodes($references);

        $this->sortChildTree($tree);

        return $tree;
    }