Get the predecessor
@return TreeNode the predecessor node
436524
public function predecessor()
    {
        if ($this->information & 2) {
            $node = $this->left;

            while ($node->information & 1) {
                $node = $node->right;
            }

            return $node;
        } else {
            return $this->left;
        }
    }
1182227
public function getDepth(){

        if($this->depth === NULL){

            if($this->isRootNode()){
                $this->depth = -1;
            }
            else{
                $parents = [$this];
                $node = $this;
                while($parent = $node->parentNode()){
                    if(!$parent->isRootNode()){
                        $parents[] = $parent;
                    }
                    $node = $parent;
                }
                $this->depth = count($parents);
            }
        }

        return $this->depth;
    }
350183
protected function getNodeRecursive()
    {
        while (false === empty($this->scope->getExpression())) {
            $currentExpression = $this->scope->getExpression();
            $this->processToken($currentExpression[0]);
            $this->processLogicalAndNode();
        }

        $this->processLastLogicalOperatorNode();

        $node = $this->scope->getNode();
        unset($this->scope);

        return $node;
    }
1154028
protected function findBaseRootElementOrNull()
    {
        $qb = parent::createBaseQueryBuilder();

        $qb->andWhere($qb->getRootAliases()[0] . '.isRoot = 1');
        $qb->andWhere($qb->getRootAliases()[0] . '.parent IS NULL');

        $root = $qb->getQuery()->getOneOrNullResult();

        return $root;
    }
361635
def get_previous_node(node):
    
    if node.prev_sibling:
        return node.prev_sibling
    if node.parent:
        return get_previous_node(node.parent)
1244751
public function previous(TraversableNodeInterface $referenceNode): TraversableNodeInterface
    {
        $referenceNodeIndex = $this->getNodeIndex($referenceNode);
        if ($referenceNodeIndex === 0) {
            throw new \InvalidArgumentException(sprintf('The node %s is the first node in the set, so there is no previous node.', $referenceNode->getNodeAggregateIdentifier()), 1542902422);
        }
        return $this->nodes[$referenceNodeIndex - 1];
    }
149194
public Object previous() {
        Object element = null;
        if (previousElement != null) {
            element = previousElement;
            previousElement = null;
        } else {
            element = getPreviousElement();
            if (element == null) {
                throw new java.util.NoSuchElementException();
            }
        }
        return element;
    }
624161
public Node root() {
        Node node = this;
        while (node.parentNode != null)
            node = node.parentNode;
        return node;
    }
987149
public function getParent()
    {
        return $this->owner
            ->hasOne($this->ownerClassName, [ $this->primaryKey => $this->parentIdField ])
            ->one();
    }
248964
public function getFirst()
    {
        $element = null;

        if (
            $this->hasParent() and
            $this->parent->hasElements()
        ) {
            $element = $this->parent->elements[0];
        }

        return $element;
    }
1162459
public function getBranchAsTree()
    {
        $lastParents = array();
        
        foreach ($this->getBranch() as $page)
        {
            if (!$page->isRoot())
            {
                $lastParents[$page->getLevel() - 1]->addNestedSetChild($page);
            }
            
            $lastParents[$page->getLevel()] = $page;
        }
        
        return $this;
    }
1240056
public Node parentNode() {

		if (currentNode == null)
			return null;

		Node node = getParentNode(currentNode);

		if (node != null)
			currentNode = node;

		return node;

	}
911673
public function getRoot() : Node {
        $node = $this;
        while ($node->parent !== null) {
            $node = $node->parent;
        }
        return $node;
    }
1025032
public function getRoot()
    {
        $tmp_parent = $this->getParent();
        $root = $tmp_parent;
        while ($tmp_parent) {
            $root = $tmp_parent;
            $tmp_parent = $tmp_parent->getParent();
        }

        return $root;
    }
647187
public function hierarchy()
    {
        if ($this->hierarchy === null) {
            $hierarchy = [];

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

            $this->hierarchy = $hierarchy;
        }

        return $this->hierarchy;
    }
581078
public function getRoot()
    {
        $next_parent = $this->getParent();
        $parent = null;
        while ($next_parent) {
            $parent = $next_parent;
            $next_parent = $parent->getParent();
        }

        return $parent ? $parent : $this;
    }
790016
public Node previousSibling() {

		if (currentNode == null)
			return null;

		Node node = getPreviousSibling(currentNode);
		if (node != null)
			currentNode = node;

		return node;
	}