Adds a navigation node as a child of this one, given a $node object
created using the create function.
@param navigation_node $childnode Node to add
@param string $beforekey
@return navigation_node The added node
348193
public function add_node(navigation_node $childnode, $beforekey=null) {
        // First convert the nodetype for this node to a branch as it will now have children
        if ($this->nodetype !== self::NODETYPE_BRANCH) {
            $this->nodetype = self::NODETYPE_BRANCH;
        }
        // Set the parent to this node
        $childnode->set_parent($this);

        // Default the key to the number of children if not provided
        if ($childnode->key === null) {
            $childnode->key = $this->children->count();
        }

        // Add the child using the navigation_node_collections add method
        $node = $this->children->add($childnode, $beforekey);

        // If added node is a category node or the user is logged in and it's a course
        // then mark added node as a branch (makes it expandable by AJAX)
        $type = $childnode->type;
        if (($type == self::TYPE_CATEGORY) || (isloggedin() && ($type == self::TYPE_COURSE)) || ($type == self::TYPE_MY_CATEGORY) ||
                ($type === self::TYPE_SITE_ADMIN)) {
            $node->nodetype = self::NODETYPE_BRANCH;
        }
        // If this node is hidden mark it's children as hidden also
        if ($this->hidden) {
            $node->hidden = true;
        }
        // Return added node (reference returned by $this->children->add()
        return $node;
    }
304291
def insertBefore(self, newchild, refchild):
		
		for i, childNode in enumerate(self.childNodes):
			if childNode is refchild:
				self.childNodes.insert(i, newchild)
				newchild.parentNode = self
				self._verifyChildren(i)
				return newchild
		raise ValueError(refchild)
1268553
public function addNode(Node $node)
    {
        $node->setNavigation($this);
        $this->nodes[] = $node;

        return $this;
    }
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);
    }
993432
protected function addNodeWithKey($key, DOMElement $element, $storage): void
    {
        if ($key === '@attributes') {
            $this->addAttributes($element, $storage);
            return;
        }

        if ($key === '@value') {

            if (\is_string($storage)) {
                $element->nodeValue = $storage;
                return;
            }

            $dom      = new \DOMDocument();
            $fragment = $element->ownerDocument->createDocumentFragment();
            $dom->loadXML(static::toXml($storage, 'root', $this->namespaces));

            /**
             * @var $childNode \DOMText
             */
            foreach ($dom->firstChild->childNodes as $childNode) {
                $fragment->appendXML($childNode->ownerDocument->saveXML($childNode));
            }

            $element->appendChild($fragment);
            return;
        }

        $this->addNode($element, $key, $storage);
    }
1307306
public function setChildNodes(array $childNodes)
    {
        /** @var $rootNode RootNode */
        $rootNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode::class);
        foreach ($childNodes as $childNode) {
            $rootNode->addChildNode($childNode);
        }
        $this->widgetContext->setViewHelperChildNodes($rootNode, $this->renderingContext);
    }
1064328
public function insertBefore(AbstractNode $child, int $id): bool
	{
		return $this->addChild($child, $id);
	}
401381
public void addChildBefore(Node newChild, Node node) {
        if (newChild.next != null)
            throw new RuntimeException(
                      "newChild had siblings in addChildBefore");
        if (first == node) {
            newChild.next = first;
            first = newChild;
            return;
        }
        Node prev = getChildBefore(node);
        addChildAfter(newChild, prev);
    }
1130446
public void insert(final Widget child, final int beforeIndex) {
        insert(child, (Element) getElement(), beforeIndex, true);
    }
799132
public function addChild(Node $child)
    {
        $this->children[]                           = $child;
        $child->parent                              = $this;
        $child->properties[$this->config['parent']] = $this->properties[$this->config['pk']];
    }
1338500
public void addChild(Node node) throws ChildNodeException {
    if (node != null) {
      if (!allowChildren) {
        throw new ChildNodeException();
      }

      if (getFirstChild() == null) {
        setFirstChild(node);
        getFirstChild().setPrevSibling(firstChild);
        getFirstChild().setNextSibling(firstChild);
      } else {    // Add it to the end of the list
        Node lastChild = getFirstChild().getPrevSibling();
        if (lastChild != null) {
          lastChild.setNextSibling(node);
        }
        node.setNextSibling(getFirstChild());
      }
      node.setParent(this);
    }
  }
1205190
private function appendNode(\DOMNode $parentNode, $data, string $nodeName, string $key = null): bool
    {
        $node = $this->dom->createElement($nodeName);
        if (null !== $key) {
            $node->setAttribute('key', $key);
        }
        $appendNode = $this->selectNodeType($node, $data);
        // we may have decided not to append this node, either in error or if its $nodeName is not valid
        if ($appendNode) {
            $parentNode->appendChild($node);
        }

        return $appendNode;
    }
1216119
protected function addBefore(string $id, string $before): Fluent
    {
        $items = [];
        $item = $this->toFluent($id);
        $keys = \array_keys($this->items);
        $position = \array_search($before, $keys);

        if ($position === false) {
            return $this->addParent($id);
        }

        foreach ($keys as $key => $fluent) {
            if ($key === $position) {
                $items[$id] = $item;
            }

            $items[$fluent] = $this->items[$fluent];
        }

        $this->items = $items;

        return $item;
    }
419682
public function addChild(Node $node, $property_name = NULL) {
    $this->appendChild($node);
    if ($property_name !== NULL) {
      $this->{$property_name} = $node;
    }
    return $this;
  }
460142
def appendChild(self, child: 'WdomElement') -> Node:
        
        if self.connected:
            self._append_child_web(child)
        return self._append_child(child)
1272455
function (oNode) {
			// if there are subnodes added to the current node -> traverse them first (added nodes are at the top, before any children)
			if (oNode.addedSubtrees.length > 0 && !oNode.nodeState.collapsed) {
				// an added subtree can be either a deep or a flat tree (depending on the addContexts) call
				for (var j = 0; j < oNode.addedSubtrees.length; j++) {
					var oSubtreeHandle = oNode.addedSubtrees[j];
					fnTraverseAddedSubtree(oNode, oSubtreeHandle);
					if (oRecursionBreaker.broken) {
						return;
					}
				}
			}
		}
95109
protected function insertAfterChild(Node $child, Node $node) {
    $this->childCount++;
    $node->parent = $this;
    if ($child->next === NULL) {
      $this->tail = $node;
    }
    else {
      $child->next->previous = $node;
    }
    $node->previous = $child;
    $node->next = $child->next;
    $child->next = $node;
    return $this;
  }