public function fetchTreeAsArray($rootId=null, $depth=null)
    {
        $config = $this->getConfiguration();
        $lftField = $config->getLeftFieldName();
        $rgtField = $config->getRightFieldName();
        $rootField = $config->getRootFieldName();
        $hasManyRoots = $config->hasManyRoots();

        if($rootId === null && $rootField !== null)
        {
            throw new \InvalidArgumentException('Must provide root id');
        }

        if($depth === 0)
        {
            return array();
        }

        $qb = $config->getBaseQueryBuilder();
        $alias = $config->getQueryBuilderAlias();

        $qb->andWhere("$alias.$lftField >= :lowerbound")
            ->setParameter('lowerbound', 1)
            ->orderBy("$alias.$lftField", "ASC");

        if($hasManyRoots)
        {
            $qb->andWhere("$alias.$rootField = :rootid")
                ->setParameter('rootid', $rootId);
        }
		
		$q = $qb->getQuery();
		if ($this->config->isQueryHintSet()){
			$q = $this->addHintToQuery($q);
		}
        $nodes = $q->execute();
		
        if(empty($nodes))
        {
            return array();
        }

        // TODO: Filter depth using a cross join instead of this
        if($depth !== null)
        {
            $nodes = $this->filterNodeDepth($nodes, $depth);
        }

        $wrappers = array();
        foreach($nodes as $node)
        {
            $wrappers[] = $this->wrapNode($node);
        }

        $this->buildTree($wrappers);

        return $wrappers;
    }