Get all descendants.

@return EnvironmentInterface[]
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;
    }
1214916
public function getAllCategoryTreesAsArray()
    {
        $rootIds = $this->getAllRootIds();

        $trees = array();
        foreach ($rootIds as $rootId) {
            $trees[$rootId] = $this->getCategoryTreeAsArray($rootId);
        }

        return $trees;
    }
1109310
public function getParents()
    {
        $parents = [];
        if ($this->parent && !$this->parent instanceof Root) {
            $parents = $this->parent->getParents();
            $parents[] = $this->parent;
        }

        return $parents;
    }
163230
protected function getChildrenList() {
        $query = (new Query)->from($this->itemChildTable);
        $parents = [];
        foreach ($query->all($this->db) as $row) {
            $parents[$row['parent']][] = $row['child'];
        }
        return $parents;
    }
671039
public function getRootNodes()
    {
        $root = [];

        foreach ($this->nodes as $appName => $nodes) {
            foreach ($nodes as $name => $migration) {
                // get the nodes  parent
                $parents = $this->getNodeFamilyTree($appName, $name)->parent;

                // if no parent exist this must be the first migration aka
                // adam/eve which ever tickles your fancy
                if (empty($parents)) {
                    $root[$appName] = $name;
                }
            }
        }

        return $root;
    }
450941
public function getAncestors()
    {
        // No need to access DB to get ancestors as they are given by the materialized path.
        //I use \/ instead of PATH_SEPARATOR for escape purpose
        $parts = preg_split('/%([^\/]+)\//', $this->materializedPath, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

        $ancestors = [];
        $countAncestors = count($parts);
        for ($i = 0; $i < $countAncestors; $i += 2) {
            $ancestors[] = [
                'id' => $parts[$i + 1],
                'name' => $parts[$i],
            ];
        }

        return $ancestors;
    }
389304
protected function getConfigTree(): array
    {
        $tree = [$this->getConfig()];
        $parent = $this->container;
        while ($parent = $parent->getParent()) {
            $tree[] = $parent->getConfig()->getConfig();
        }

        return $tree;
    }
775974
public static function getRemoteEnvironments()
    {
        $environments = [];

        foreach (self::getProjectConfig()->getRemote() as $remote) {
            foreach ($remote as $environment) {
                if (!isset($environment['realm'])) {
                    continue;
                }
                $realm = $environment['realm'];
                unset($environment['realm']);

                $environments[$realm][] = $environment;
            }
        }

        return $environments;
    }
94904
private function getRootNodes()
    {
        $output = array();
        foreach( $this->nodes as $node )
            if (! $node->parentCount() )
                $output[] = $node;
        return $output;
    }
787179
public function getEnvironments()
    {
        $project = $this->getProject();
        if (!$project) {
            return [];
        }

        return array_keys($this->api->getEnvironments($project, false, false));
    }
941029
public function findAll()
	{
		$a = [];
		foreach ($this->parents as $x => $r) {
			$a[$x] = $this->find($x);
		}
		return $a;
	}
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;
    }
720939
public function findAll()
    {
        $appNodes = array();
        foreach ($this->getSystemConfiguration()->getApps() as $appNode) {
            $appNodes[$appNode->getPrimaryKey()] = $appNode;
        }
        return $appNodes;
    }
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);
	}
461995
public function getAllParents()
    {
        $parents = array();

        $parent = $this;

        while ($parent = $parent->getParent()) {
            $parents[] = $parent;
        }

        return $parents;
    }
178839
public function getAncestors() {
        $ancestors=new ArrayList();
        $object   =$this->owner;
        
        while($object=$object->Language()) {
            $ancestors->push($object);
        }
        
        return $ancestors;
    }
1060639
public function findAll()
    {
        $deploymentNodes = array();
        foreach ($this->getSystemConfiguration()->getContainers() as $container) {
            $deploymentNode = $container->getDeployment();
            $deploymentNodes[$deploymentNode->getUuid()] = $deploymentNode;
        }
        return $deploymentNodes;
    }