Make node $node a child of $newParent If this is an ordered tree,
the position should be the last

@param \BeeTree\Contracts\Node $node The moved or inserted node
@param \BeeTree\Contracts\Node $newParent The parent node
@return self
547506
protected function performMakeChildOf(Node $node, Node $newParent)
    {

        $parentIdName = $this->getParentIdName();
        $rootIdName = $this->getRootIdName();

        // The node is already a child of newParent
        if ( ($node->getParentId()== $newParent->getId()) && $node->exists ) {
            return $this;
        }

        // Copy foreign keys
        $node[$parentIdName] = $newParent->getId();
        $node[$rootIdName] = $newParent[$rootIdName];

        // Set in-memory relations
        $node->setParent($newParent);
        $newParent->addChild($node);

        return $this;

    }
273882
public function appendNode($new_node)
    {
        $pos = $this->count();
        $new_node->setPosition($pos);
        $this->push($new_node);
    }
159980
public function removeChild(self $node)
	{
		if ($node->getParent() !== $this) {
			$msg = sprintf('Cannot remove %s from %s because it is not a child.', $node, $this);
			throw new InvalidArgumentException($msg);
		}
		$this->removeChildAt($node->getChildIndex());
		return $this;
	}
540558
public function append(NodeDefinition $node)
    {
        if ($node instanceof ParentNodeDefinitionInterface) {
            $builder = clone $this;
            $builder->setParent(null);
            $node->setBuilder($builder);
        }

        if (null !== $this->parent) {
            $this->parent->append($node);
            // Make this builder the node parent to allow for a fluid interface
            $node->setParent($this);
        }

        return $this;
    }
1009627
public function replace(DOMElement &$old, &$new)
    {
        // Check if the element has a parent node
        if (empty($old->parentNode)) {
            throw new DOMException('The current DOMItem has no parent.');
        }

        // Replace the element
        $old->parentNode->replaceChild($new, $old);

        return $new;
    }
13340
private Node getParentNode(Node node) {

		if (node == null || node == root)
			return null;

		Node newNode = node.getParentNode();
		if (newNode == null)
			return null;

		int accept = acceptNode(newNode);

		if (accept == NodeFilter.FILTER_ACCEPT)
			return newNode;
		else
			// if (accept == NodeFilter.SKIP_NODE)
			// and REJECT too.
			return getParentNode(newNode);

	}
58558
public function set_parent(navigation_node $parent) {
        // Set the parent (thats the easy part)
        $this->parent = $parent;
        // Check if this node is active (this is checked during construction)
        if ($this->isactive) {
            // Force all of the parent nodes open so you can see this node
            $this->parent->force_open();
            // Make all parents inactive so that its clear where we are.
            $this->parent->make_inactive();
        }
    }
130489
public function addChild(Node $node, $key = null)
    {
        if ($key === null) {
            $this->children[] = $node;
        } else {
            $this->children[ $key ] = $node;
        }

        return $node;
    }
648402
public function replace($newNode, $clone = true)
    {
        if ($this->node->parentNode === null) {
            throw new LogicException('Can not replace element without parent node');
        }

        if ($newNode instanceof Element) {
            $newNode = $newNode->getNode();
        }

        if (!$newNode instanceof DOMNode) {
            throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMNode, %s given', __METHOD__, __CLASS__, (is_object($newNode) ? get_class($newNode) : gettype($newNode))));
        }

        if ($clone) {
            $newNode = $newNode->cloneNode(true);
        }

        if ($newNode->ownerDocument === null || !$this->getDocument()->is($newNode->ownerDocument)) {
            $newNode = $this->node->ownerDocument->importNode($newNode, true);
        }

        $node = $this->node->parentNode->replaceChild($newNode, $this->node);

        return new Element($node);
    }
486667
protected function newlineAfter(Node $node) {
    $next = $node->nextToken();
    if ($next instanceof WhitespaceNode) {
      $next->setText($this->getNewlineIndent($next));
    }
    else {
      $node->after(Token::whitespace($this->getNewlineIndent()));
    }
  }
573732
public function moveAsFirstChildOf(NodeInterface $parentNode)
	{
		$this->validateAddingChildren($parentNode);
		
		$pos = $parentNode->getLeftValue() + 1;
		$level = $parentNode->getLevel() + 1;
		$this->move($pos, $level);

		return $this;
	}
556471
public function move($oldParent, $newParent)
    {
        return $oldParent->removeChild($this)
            ? $newParent->addChild($this)
            : false;
    }
929845
public static function fromNode(Node $node): self
    {
        return new self($node::schema()->getQName(), (string)$node->get('_id'));
    }
747195
public function setParent(Zend_Server_Reflection_Node $node, $new = false)
    {
        $this->_parent = $node;

        if ($new) {
            $node->attachChild($this);
            return;
        }
    }
216251
protected function appendChild(Node $node) {
    if ($this->tail === NULL) {
      $this->prependChild($node);
    }
    else {
      $this->insertAfterChild($this->tail, $node);
      $this->tail = $node;
    }
    return $this;
  }
1092870
public function resolvePreviousNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->prev() !== null) {
            $new_node->moveNodeAsChild($new_node->prev());
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }
232635
public static function get_block_parent( \DOMNode $node ) {
		$parent = $node->parentNode;
		if ( ! $parent instanceof \DOMElement ) {
			return null;
		}

		while ( ! self::is_block_tag( $parent ) && $parent->parentNode instanceof \DOMElement ) {
			/**
			 * The parent is sure to be a \DOMElement.
			 *
			 * @var \DOMElement
			 */
			$parent = $parent->parentNode;
		}

		return $parent;
	}