Return parents id, ordered by level
@param boolean $includeSelf
@return integer[]
961217
public function getParentsId($includeSelf = false)
    {
        $cacheKey = [
            'class' => self::className(),
            'ownerClass' => $this->ownerClassName,
            'method' => 'getParentsId',
            'id' => $this->owner->{$this->primaryKey},
        ];
        if ( $this->owner->{$this->parentIdField} ) {
            $parents = $this->cache->getOrSet($cacheKey, function(){
                return self::getParentsIdRec($this->owner->{$this->parentIdField}, $this->ownerClassName, $this->primaryKey, $this->parentIdField);
            }, null, $this->getTagDependency());
        } else {
            $parents = [];
        }
        return $includeSelf ? array_merge($parents, [$this->owner->{$this->primaryKey}]) : $parents;
    }
883547
function(fn, includeSelf) {
			var i,
				l,
				n,
				ac = this.parent.children;

			for (i = 0, l = ac.length; i < l; i++) {
				n = ac[i];
				if (includeSelf || n !== this) {
					if (fn(n) === false) {
						return false;
					}
				}
			}
			return true;
		}
390913
public static function getParent($list, $id)
    {
        if (!is_array($list)) return [];
        $temp = [];
        foreach ($list as $v) {
            $temp[$v[self::$config['id']]] = $v;
        }
        $parentid = $temp[$id][self::$config['pid']];
        return $temp[$parentid];
    }
424492
public function getAncestors($includeSelf = false)
    {
        $ancestors = new ArrayList();
        $object = $this->owner;

        if ($includeSelf) {
            $ancestors->push($object);
        }
        while ($object = $object->getParent()) {
            $ancestors->push($object);
        }

        return $ancestors;
    }
529692
public function getAllowedEntityIds(PermissionDefinition $permissionDef)
    {
        $rootEntity = $permissionDef->getEntity();
        if (empty($rootEntity)) {
            throw new InvalidArgumentException('You have to provide an entity class name!');
        }
        $builder = new MaskBuilder();
        foreach ($permissionDef->getPermissions() as $permission) {
            $mask = constant(get_class($builder) . '::MASK_' . strtoupper($permission));
            $builder->add($mask);
        }

        $query = new Query($this->em);
        $query->setHint('acl.mask', $builder->get());
        $query->setHint('acl.root.entity', $rootEntity);
        $sql = $this->getPermittedAclIdsSQLForUser($query);

        $rsm = new ResultSetMapping();
        $rsm->addScalarResult('id', 'id');
        $nativeQuery = $this->em->createNativeQuery($sql, $rsm);

        $transform = function ($item) {
            return $item['id'];
        };
        $result = array_map($transform, $nativeQuery->getScalarResult());

        return $result;
    }
519715
public function getNodeAncestors($maxLevel = 3)
    {
        $ancestors = [];
        $level = 0;

        $node = $this->parentNode;

        while ($node && !($node instanceof DOMDocument)) {
            $ancestors[] = $node;
            $level++;
            if ($level === $maxLevel) {
                break;
            }
            $node = $node->parentNode;
        }

        return $ancestors;
    }
808221
public function ancestors($includeSelf = false, $depth = null)
    {
        $this
            ->getQuerySet()
            ->ancestors($includeSelf, $depth);

        return $this;
    }
1226231
public function getParentContentUids(array $contents)
    {
        $elementUids = [];
        $notElementUids = [];
        foreach ($contents as $content) {
            if (!($content instanceof AbstractClassContent)) {
                continue;
            }

            if ($content->isElementContent()) {
                $elementUids[] = $content->getUid();
            } else {
                $notElementUids[] = $content->getUid();
            }
        }

        if (count($elementUids)) {
            $query = $this->_em->getConnection()
                    ->createQueryBuilder()
                    ->select('j.parent_uid')
                    ->from('content_has_subcontent', 'j');

            $notElementUids = array_merge(
                    $notElementUids,
                    $this->executeQueryIn($query, 'j.content_uid', $elementUids)
            );
        }

        if (count($notElementUids)) {
            $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');
            $query = $this->_em->getConnection()
                    ->createQueryBuilder()
                    ->select('c.'.$meta->getColumnName('content_uid'))
                    ->from($meta->getTableName(), 'c');

            return $this->executeQueryIn($query, 'c.'.$meta->getColumnName('subcontent_uid'), $notElementUids);
        }

        return [];
    }
1235594
public function getParent($parentId)
    {
        if ($parentId && isset($this->site->pages[$parentId])) {
            return $this->site->pages[$parentId];
        }

        return [];
    }
462723
public function getMultiOptions($includeSelf = true)
    {
        $this->_tmpResult = [];
        if (!$this->isNewRecord && $includeSelf) {
            $this->_tmpResult[$this->id] = $this;
        }
        return $this->_buildTreeArrayRecursive($this, $this->_filter);
    }
353100
public function getElementalRelations()
    {
        $hasOnes = $this->owner->hasOne();

        if (!$hasOnes) {
            return false;
        }

        $elementalAreaRelations = [];

        foreach ($hasOnes as $hasOneName => $hasOneClass) {
            if ($hasOneName === 'Parent' || $hasOneName === 'ParentID') {
                continue;
            }

            if ($hasOneClass == ElementalArea::class || is_subclass_of($hasOneClass, ElementalArea::class)) {
                $elementalAreaRelations[] = $hasOneName;
            }
        }

        return $elementalAreaRelations;
    }
1082572
public function getIndexes( $includeParents = true )
    {

        // lazy load indexes
        if( !isset( $this->indexes ) ) {

            $this->indexes = $this->catalog->pgIndexes->findByIndrelid( $this->oid );

            // are we inheriting off another table
            if( $parent = $this->getParent() ) {

                foreach( $parent->getIndexes() as $parentIndex ) {

                    $data = $parentIndex->all();
                    $data['inherited'] = true;
                    $data['columns'] = [];

                    foreach( $parentIndex->indkey as $indkey ) {
                        $columns[] = sprintf( "%s.%s", $this->oid, $indkey );
                    }

                    $this->indexes->add(
                        new PgIndex( $this->catalog, $data )
                    );

                }

            }

        }

        // include parent indexes
        if( $includeParents ) {
            return $this->indexes->copy();
        } else {
            return $this->indexes->copy()->removeByInherited( true );
        }

    }
1041338
protected function getParentsHierarchyField() {
		// see if we've got Parent values
        $parents = array();

        $parent = $this->owner;
        while ($parent && $parent->ParentID) {
            $parents[] = (int) $parent->ParentID;
            $parent = $parent->Parent();
            // fix for odd behaviour - in some instance a node is being assigned as its own parent. 
            if ($parent->ParentID == $parent->ID) {
                $parent = null;
            }
        }
        return $parents;
	}
570196
public function findAllExceptTreeByParentId($parent_id)
    {
        $qb = $this->createQueryBuilder();

        $qb = $this->alterQueryBuilderExceptWithParentRoot($qb, $parent_id);

        $qb->orderBy($qb->getRootAliases()[0] . '.lft', 'ASC');

        return $this->getResultFromQueryBuilder($qb);
    }
652501
public function getParentsList()
    {
        /** @var static $root */
        $root  = static::root();
        $items = [
            ['id' => '1', 'title' => 'Item Root'],
        ];

        if ($this->exists) {
            $parents = $this->ancestors()
                            ->withoutRoot()
                            ->orWhere(function ($query) {
                                $query->where('depth', $this->depth)->where('id', '<>', $this->id);
                            })
                            ->get();
            foreach ($parents as $parent) {
                $items[] = [
                    'title' => $parent->present()->indentedTitle(),
                    'id'    => $parent->id,
                ];
            }
        } else {
            foreach ($root->getDescendants() as $parent) {
                $items[] = [
                    'title' => $parent->present()->indentedTitle(),
                    'id'    => $parent->id,
                ];
            }
        }

        return array_pluck($items, 'title', 'id');
    }
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];
        }
    }
250407
public function getDescendants($levelLimit = 0, $includeNode = false)
	{
		$left = $this->getLeftValue();
		$right = $this->getRightValue();
		$level = $this->getLevel();

		$searchCondition = $this->repository->createSearchCondition();
		if ($includeNode) {
			$searchCondition->leftGreaterThanOrEqualsTo($left)
					->rightLessThanOrEqualsTo($right);
		} else {
			$searchCondition->leftGreaterThan($left)
					->rightLessThan($right);
		}

		if ($levelLimit < 0) {
			throw new Exception\Domain("Level limit cannot be negative in getDescendants method");
		} elseif ($levelLimit > 0) {
			$searchCondition->levelLessThanOrEqualsTo($level + $levelLimit);
		}

		$orderRule = $this->repository->createSelectOrderRule()
				->byLeftAscending();

		$descendants = $this->repository->search($searchCondition, $orderRule);
		
		return $descendants;
	}