Resolve node.

@param NodeContract $node

@return NodeContract
763565
public function resolve(NodeContract $node)
    {
        $this->resolveParenthesis($node);
        $this->resolveGrouping($node);

        return $node;
    }
165728
protected function resolveNode( $model )
	{
		if ( $model instanceof NestedModel )
			return $model->reload();

		return $this->model->newNestedSetQuery()->find( $model );
	}
610217
protected function getFirstExternalNode($node)
    {
        $nodes = func_get_args();
        foreach ($nodes as $node) {
            /** @var Node $node */
            if ($node->isLocalhost() === false) {
                return $node;
            }
        }

        return null;
    }
1339425
protected function traverseNode(Node $node) : Node
    {
        foreach ($node->getSubNodeNames() as $name) {
            $subNode =& $node->$name;

            if (\is_array($subNode)) {
                $subNode = $this->traverseArray($subNode);
                if ($this->stopTraversal) {
                    break;
                }
            } elseif ($subNode instanceof Node) {
                $traverseChildren = true;
                foreach ($this->visitors as $visitor) {
                    $return = $visitor->enterNode($subNode, $traverseChildren);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::DONT_TRAVERSE_CHILDREN === $return) {
                            $traverseChildren = false;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } else {
                            throw new \LogicException(
                                'enterNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }

                if ($traverseChildren) {
                    $subNode = $this->traverseNode($subNode);
                    if ($this->stopTraversal) {
                        break;
                    }
                }

                foreach ($this->visitors as $visitor) {
                    $return = $visitor->leaveNode($subNode);
                    if (null !== $return) {
                        if ($return instanceof Node) {
                            $subNode = $return;
                        } elseif (self::STOP_TRAVERSAL === $return) {
                            $this->stopTraversal = true;
                            break 2;
                        } elseif (\is_array($return)) {
                            throw new \LogicException(
                                'leaveNode() may only return an array ' .
                                'if the parent structure is an array'
                            );
                        } else {
                            throw new \LogicException(
                                'leaveNode() returned invalid value of type ' . gettype($return)
                            );
                        }
                    }
                }
            }
        }

        return $node;
    }
619426
public function resolveConstructor(Node\Stmt\Class_ $node)
    {
        foreach ($node->stmts as $key => $stmt) {
            if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
                // this will make problems we need an layer above which chains the variable resolvers
                // because we need may need more than this resolver

                // skip constructor if is abstract
                if ($stmt->isAbstract()) {
                    return $node;
                }

                // change recursivly the nodes
                $subTraverser = new NodeTraverser();
                foreach ($this->visitors as $visitor) {
                    $subTraverser->addVisitor($visitor);
                }

                // the table switches to a method scope
                // $x = ... will be treated normal
                // $this->x = ... will be stored in the above class scope and is available afterwards
                $this->table->enterScope(new TableScope(TableScope::CLASS_METHOD_SCOPE));
                $subTraverser->traverse($stmt->params);
                $nodes = $subTraverser->traverse($stmt->stmts);
                $this->table->leaveScope();

                //override the old statement
                $stmt->stmts = $nodes;

                // override the classmethod statement in class
                $node->stmts[$key] = $stmt;

                // return the changed node to override it
                return $node;
            }
        }

        // no constructor defined
        return $node;
    }
433090
public function addChild(NodeContract $child)
    {
        $this->children[] = $child;

        $child->setParent($this);
        $child->setIndex(count($this->children) - 1);

        return $this;
    }
538996
public function enterNode(Node $node)
    {
        if ($node instanceof ConstFetch || $node instanceof FuncCall) {
            $node->name = null;
        }

        if ($node instanceof FullyQualified) {
            $this->names[] = $node->toString();
        }

        return $node;
    }
1266985
private function arrayDeference(Node $node) {
    while ($this->currentType === '[') {
      $n = $node;
      $node = new ArrayLookupNode();
      $node->addChild($n, 'array');
      $this->dimOffset($node);
    }
    return $node;
  }
519276
public function append(Node $node)
    {

        if (!is_array($this->_children)) {
            $this->_children = [];
        }

        $this->_children[] = $node;
        return $this;
    }
1115462
public function remove(Node $node)
    {

        // Collect the parentId to correct the positions of its old ancestors
        $parentId = $node->getParentId();
        $position = $node->getPosition();

        $this->performRemove($node);

        if($parentId){
            $this->decrementOrderAfter($parentId, $position);
        }

        return $this;
    }
1238775
private function getExpression(Node $node) {
		if ($node instanceof ConstFetch) {
			$const = $node->name->parts[0];
			if (isset($this->constMap[$const])) {
				return $this->constMap[$const];
			}
	
			return $const;
		}
		
		if ($node instanceof ClassConstFetch) {
			return $node->class->parts[0] . '::' . $node->name;
		}
	
		if ($node instanceof MagicConst) {
			return $node->getName();
		}
		
		if ($node instanceof Array_) {
			$prettyPrinter = new PrettyPrinter();
			return $prettyPrinter->prettyPrintExpr($node);
		}
	}
467312
public static function removeAndGetNext($node)
    {
        $nextNode = self::getNextNode($node, true);
        $node->parentNode->removeChild($node);

        return $nextNode;
    }
602781
private function getOuterMostArrayNode(Node $node): Node
    {
        $outerMostArrayParent = $node;

        do {
            if ($node instanceof Node\Expr\Array_) {
                $outerMostArrayParent = $node;
            }
        } while ($node = $node->getAttribute(ParentConnectorVisitor::PARENT_KEY));

        return $outerMostArrayParent;
    }
333145
protected function htmlFromNode($node)
    {
        $domDocument = new \DOMDocument();
        $newNode = $domDocument->importNode($node, true);
        $domDocument->appendChild($newNode);

        return $domDocument->saveHTML();
    }
659372
public function addChild(Node $node)
    {
        if($node instanceof NodeWrapper)
        {
            if($node == $this)
            {
                throw new \InvalidArgumentException('Cannot insert node as a child of itself');
            }

            $node->insertAsLastChildOf($this);
            return $node;
        }

        $node->setLeftValue($this->getRightValue());
        $node->setRightValue($this->getRightValue() + 1);
        if($this->hasManyRoots())
        {
            $node->setRootValue($this->getRootValue());
        }

        $em = $this->getManager()->getEntityManager();

        // beginTransaction
        $em->getConnection()->beginTransaction();
        try
        {
            $this->shiftRLRange($this->getRightValue(), 0, 2, ($this->hasManyRoots() ? $this->getRootValue() : null));

            $em->persist($node);

            $em->flush();
            $em->getConnection()->commit();
        }
        catch (\Exception $e)
        {
            // @codeCoverageIgnoreStart
            $em->close();
            $em->getConnection()->rollback();
            throw $e;
            // @codeCoverageIgnoreEnd
        }
        // endTransaction

        return $this->getManager()->wrapNode($node);
    }
238809
public function setNode(NodeInterface $node = null)
    {
        $this->node = $node;

        if ($node->getMenu() !== $this) {
            $node->setMenu($this);
        }

        return $this;
    }
338031
public function resolveNextNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->next() && $new_node->next() instanceof ComparableNodeContract) {
            $new_node->moveNodeAsChild($new_node->next());
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }