Return direct children of given root's id
@param $id
@return BaseEntity[]
510957
public function getChildren($id)
    {
        $table = $this->getTable();
        $closure = $table . '_closure';
        $tableAlias = 'c';
        $closureAlias = 'cc';
        $primaryKey = $this->mapper->getPrimaryKey($table);
        $fluent = $this->connection->command()
            ->select('%n.*', $tableAlias)
            ->from('%n AS %n', $table, $tableAlias)
            ->join('%n AS %n', $closure, $closureAlias)
            ->on('%n.%n = %n.descendant', $tableAlias, $primaryKey, $closureAlias)
            ->where('%n.ancestor = %s', $closureAlias, $id)
            ->where('%n.depth = 1', $closureAlias);

        $entityClass = $this->mapper->getEntityClass($this->getTable());
        $rc = new ReflectionClass($entityClass);
        $closureEntityClass = $entityClass . 'Closure';
        if ($rc->implementsInterface('Joseki\LeanMapper\ClosureTable\ISortable')) {
            $fluent->orderBy('%n.order', $tableAlias);
        } else if (class_exists($closureEntityClass)) {
            /** @var Entity $closureEntity */
            $closureEntity = new $closureEntityClass;
            if ($closureEntity->getReflection($this->mapper)->getEntityProperty('order')) {
                $fluent->orderBy('%n.order', $closureAlias);
            }
        }

        return $this->createEntities($fluent->fetchAll());
    }
1125781
private function getParentsIdRec($id, $className, $primaryKey, $parentIdField)
    {
        $parentId = (int)$className::find()->select($parentIdField)->where([ $primaryKey => $id ])->scalar();
        if ( $parentId ) {
            return array_merge(self::getParentsIdRec($parentId, $className, $primaryKey, $parentIdField), [$id]);
        } else {
            return [$id];
        }
    }
1135911
public function getSons($id)
    {
        $sons = [];
        foreach ($this->_tree as $key => $value) {
            if ($value[$this->_parentSign] == $id) {
                $sons[] = $value;
            }
        }
        return $sons;
    }
1373410
public function getAncestor($id)
    {
        if ( ! is_null($this->parent)) {
            if ($this->parent->id() == $id) {
                return $this->parent;
            }

            return $this->parent->getAncestor($id);
        }

        return null;
    }
997155
public function getTree($id = null) {
        $parent = $this->getConfig('parentField');
        $left = $this->getConfig('leftField');
        $right = $this->getConfig('rightField');

        $query = $this->getRepository()->select()->orderBy($left, 'asc');

        if ($id) {
            if ($parentNode = $this->getNode($id)) {
                $query->where($left, 'between', [$parentNode[$left], $parentNode[$right]]);
            } else {
                return [];
            }
        }

        $nodes = $query->all();

        if ($nodes->isEmpty()) {
            return [];
        }

        $map = [];
        $stack = [];
        $pk = $this->getRepository()->getPrimaryKey();

        foreach ($nodes as $node) {
            if ($node[$parent] && $node[$pk] != $id) {
                $map[$node[$parent]][] = $node;
            } else {
                $stack[] = $node;
            }
        }

        $results = $this->mapTree($stack, $map);

        if ($id) {
            return $results[0];
        }

        return $results;
    }
24740
public function getChilds($id)
    {
        $result = [];
        if (array_key_exists($id, $this->finder)) {
            return $this->recursiveGetChilds($this->finder[$id][$this->config['childs']], $result);
        } else {
            return $result;
        }
    }
1009630
public function getRootItem($id)
    {
        return isset($this->menuRootItems[$id]) ? $this->menuRootItems[$id] : null;
    }
272064
public function RecallDaftNestedObjectTreeWithId(
        $id,
        bool $includeRoot,
        ? int $relativeDepthLimit
    ) : array {
        $object = $this->RecallDaftObject($id);

        /**
        * @var array<int, DaftNestedObject>
        *
        * @psalm-var array<int, T>
        */
        $out =
            ($object instanceof DaftNestedObject)
                ? $this->RecallDaftNestedObjectTreeWithObject(
                    $object,
                    $includeRoot,
                    $relativeDepthLimit
                )
                : (
                    ((array) $id === $this->GetNestedObjectTreeRootId())
                        ? $this->RecallDaftNestedObjectFullTree($relativeDepthLimit)
                        : []
                );

        return $out;
    }
179791
public function getAncestry($id)
    {
        $all_results = new Collection(DB::select($this->getAncestryInitialQuery(), [':id' => $id]));

        if (count($all_results)) {
            $this->getRecursiveAncestry($all_results, $all_results->lists('parent_id'));
        }

        return $all_results;
    }
811227
public function childrensAction($id) {
        $em = $this->getDoctrine()->getManager();

        $parent = $em->getRepository('AmulenClassificationBundle:Category')->findOneBy(array("id" => $id));
        $childrens = $em->getRepository('AmulenClassificationBundle:Category')->getChildren($parent, true);

        return array(
            'entities' => $childrens,
            'parent' => $parent,
        );
    }
1333159
public function getRecipeById($id)
    {
        $result = [
            'className' => (isset($this->classNameById[$id])) ?
                $this->classNameById[$id] :
                null,
            'arguments' => (isset($this->argumentsById[$id])) ?
                $this->argumentsById[$id] :
                null,
            'constructor' => (isset($this->constructorById[$id])) ?
                $this->constructorById[$id] :
                null,
            'dependencies' => (isset($this->dependenciesById[$id])) ?
                $this->dependenciesById[$id] :
                null,
        ];

        return $result;
    }
718345
public function getParentId($id)
    {
        $path = $this->getProperty($id, self::PATH);
        array_pop($path);

        return empty($path)
            ? null // the given item is the root
            : array_pop($path);
    }
124194
public function getPath( $id )
	{
		$list = $this->manager->getPath( $id, $this->domains );

		if( $this->root )
		{
			foreach( $list as $key => $item )
			{
				if( $key == $this->root ) {
					break;
				}
				unset( $list[$key] );
			}
		}

		return $list;
	}
1026671
public function getMultilevelChildren($id, array $options = [])
	{
		$options['for']    = $id;
		$options['direct'] = false;

		$options['for']    = $id;
		$options['direct'] = false;

		$query    = $this->_table->find();
		$iterator = $this->findChildren($query, $options);

		$primaryKey = $this->_table->getSchema()->primaryKey();
		$primaryKey = count($primaryKey) == 1 ? $primaryKey[0] : $primaryKey;

		$parent_id_fieldname = $this->getConfig('model_parent_id_fieldname');

		$nodes_by_pk = [];
		$root_nodes  = [];

		foreach($iterator as $node)
		{
			$nodes_by_pk[$node->{$primaryKey}] = $node;

			if($node->{$parent_id_fieldname} == $id)
			{
				$root_nodes[] = $node;
			}

			if(isset($nodes_by_pk[$node->{$parent_id_fieldname}]))
			{
				if(!isset($nodes_by_pk[$node->{$parent_id_fieldname}]->children))
				{
					$nodes_by_pk[$node->{$parent_id_fieldname}]->children = [];
				}

				$nodes_by_pk[$node->{$parent_id_fieldname}]->children[] = $node;
			}
		}
		unset($node);

		return new \Cake\Collection\Collection($root_nodes);
	}
1143208
public function getDefaultValues($id = null)
    {
        if ($id === null) {
            return array();
        }
        $entity = $this->getById($id);
        $values = $this->getDefaultFormValues($entity);
        return $values;
    }
390292
public function findById($id, $withParents = false)
    {
        $parents = [];
        foreach ($this->build() as $element) {
            if (null !== ($found = $this->_findInChildren($element, $id, $withParents, $parents))) {
                if ($withParents) {
                    $found['parents'] = array_reverse($parents);
                }
                return $found;
            }
        }
    }
895525
public function getRole(string $id = null): array
    {
        if ($id) {
            if (is_numeric($id)) {
                $filter = array_filter($this->role, function ($row) use ($id) { return $row['id'] == $id; });
                return (array) array_pop($filter);
            }
            return (array) ($this->role[$id] ?? []);
        }
        return $this->role;
    }