gets descendants for this node

@param int $depth or null for unlimited depth

@return array array of NodeWrapper objects
519856
public function getDescendants($depth = null)
    {
        if(!$this->hasChildren())
        {
            return array();
        }

        if($this->descendants === null)
        {
            $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder();
            $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias();

            $qb->andWhere("$alias.".$this->getLeftFieldName()." > :lft1")
                ->setParameter('lft1', $this->getLeftValue())
                ->andWhere("$alias.".$this->getRightFieldName()." < :rgt1")
                ->setParameter('rgt1', $this->getRightValue())
                ->orderBy("$alias.".$this->getLeftFieldName(), "ASC");
            if($this->hasManyRoots())
            {
                $qb->andWhere("$alias.".$this->getRootFieldName()." = :root")
                    ->setParameter('root', $this->getRootValue());
            }

            // TODO: Add depth support or self join support?
			$q = $qb->getQuery();
			if ($this->getManager()->getConfiguration()->isQueryHintSet()){
				$q = $this->getManager()->addHintToQuery($q);
			}
            $results = $q->getResult();

            $this->descendants = array();
            foreach($results as $result)
            {
                $this->descendants[] = $this->getManager()->wrapNode($result);
            }
        }

        if($depth !== null)
        {
            // TODO: Don't rebuild filtered array everytime?
            return $this->getManager()->filterNodeDepth($this->descendants, $depth);
        }

        return $this->descendants;
    }
124951
public function getFlattenChildren(Node $node)
    {
        $flatten = array();
        foreach ($node->getNodes() as $subNode) {
            if (count($subNode->getNodes()) > 1 || isset($subNode->getTrace()['query_source']) || !empty($subNode->getValues())) {
                $flatten[] = $subNode;
            } else {
                $flatten = array_merge($flatten, $this->getFlattenChildren($subNode));
            }
        }

        return $flatten;
    }
1267378
public function getParents($depth = null)
    {
        /** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
        $query = $this->owner->find();
        return $query->parentsOf($this->owner, $depth);
    }
1339312
def get_children(self, depth=1):
        """"""
        yield self
        if depth == 0: return
        for child in self.children.values():
            for node in child.get_children(depth-1): yield node
30732
public function getParent ($category, $depth = 1)
		{
			if ($category instanceof $this->_modelClass and $depth > 0)
			{
				if ($category->depth == $depth)
					return $category;
				foreach ($this->_data as $item)
					if ($category->lft > $item->lft and $category->rgt < $item->rgt and $item->depth == $depth)
						return $item;
			}

			return null;
		}
820178
private function searchTree($depth = 0)
    {
        $this->depth = $depth;
        foreach ($this->children->getList() as $node) {
            if ($depth > count($this->treePath)) {
                break;
            }

            if ($this->treePath[$depth] != $node->key) {
                continue;
            }

            /**
             * @var $node TreeNode
             */
            if (count($this->treePath) > $depth && $this->allowedToDiveDeeper($depth)) {
                $node->setTreepath($this->treePath);

                return $node->searchTree(++$depth);
            }
        }

        return $this;
    }
590303
public function children($depth = false)
    {
        return $this->menu->whereParentId($this->id, $depth)->all();
    }
1193504
public function getPages($deep = false)
    {
        if ($this->has('Kids')) {

            if (!$deep) {
                return $this->get('Kids')->getContent();
            } else {
                $kids  = $this->get('Kids')->getContent();
                $pages = array();

                foreach ($kids as $kid) {

                    if ($kid instanceof Pages) {
                        $pages = array_merge($pages, $kid->getPages(true));
                    } else {
                        $pages[] = $kid;
                    }
                }

                return $pages;
            }
        }

        return array();
    }
495220
public function parents($depth = null) {
        $condition = [
            'and',
            [$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]],
            [$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]],
        ];

        if ($depth !== null) {
            $condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]];
        }

        $this->applyTreeAttributeCondition($condition);

        return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);
    }
705210
public function getChildren()
    {
        if ($this->children === null) {
            $this->setChildren($this->environmentRepository->getAllChildren($this));
        }
        return $this->children;
    }
317641
public function getFirstDescendantNode(...$classNames) {
        foreach ($this->getDescendantNodes() as $descendant) {
            foreach ($classNames as $className) {
                if ($descendant instanceof $className) {
                    return $descendant;
                }
            }
        }
        return null;
    }
488021
public function descendants($level = null)
	{
		$instance = self::blank();
		$instance->where('level', '>', $this->level)
		         ->order('lft', 'asc');

		if (isset($level))
		{
			$instance->where('level', '<=', $this->level + $level);
		}

		return $instance->where('lft', '>', $this->lft)
		                ->where('rgt', '<', $this->rgt)
		                ->applyScopesWhere($this);
	}
1026785
public function getDescendants()
    {
        $descendants = [];

        $descendants[$this->name] = $this->appName;

        /** @var $child Node */
        foreach ($this->children as $child) {
            $childDescendats = $child->getDescendants();
            $descendants = array_merge($childDescendats, $descendants);
        }

        return $descendants;
    }
485540
public function getDescendants()
    {
        $descendants = [];
        if ($this->hasChildren()) {
            foreach ($this->getChildren() as $child) {
                $childDescendants = $child->hasChildren() ? $child->getDescendants() : [];
                $descendants = ArrayUtils::merge($descendants, ArrayUtils::merge([$child], $childDescendants));
            }
        }
        return $descendants;
    }
393063
public function rootNodes()
    {
        $query = $this->model->newQuery()->whereNull($this->parentIdKey);

        $this->callBeforeListeners('rootNodes', [$query]);

        $nodes = $query->get()->all();

        $this->callAfterListeners('rootNodes', [$nodes]);

        return $nodes;
    }
335858
public function get($path, $depth = 0)
    {
        $node = $this->nodeRepoForDepth($depth)->getByPathOrFail($path);
        return $this->ensureEloquentFile($node);
    }
383078
def get_descendants(self):
        
        return self.__class__.get_tree(self).exclude(pk=self.pk)