Replace child node with other nodes
@param ParseNode node to replace
@param array replacement
@param ParseNode
352544
function splice( ParseNode $Node, array $nodes ){
		foreach( $this->children as $i => $Child ){
			if( $Child->idx === $Node->idx ){
				return $this->splice_at( $i, $nodes, 1 );
			}
		}	
	}
258071
public Node replaceNode(Closure c) {
        if (parent() == null) {
            throw new UnsupportedOperationException("Replacing the root node is not supported");
        }
        appendNodes(c);
        getParentList(parent()).remove(this);
        this.setParent(null);
        return this;
    }
379046
public final void replaceChild(Node child, Node newChild) {
    checkArgument(newChild.next == null, "The new child node has next siblings.");
    checkArgument(newChild.previous == null, "The new child node has previous siblings.");
    checkArgument(newChild.parent == null, "The new child node already has a parent.");
    checkState(child.parent == this, "%s is not the parent of %s", this, child);

    // Copy over important information.
    newChild.useSourceInfoIfMissingFrom(child);
    newChild.parent = this;

    Node nextSibling = child.next;
    Node prevSibling = child.previous;

    Node last = first.previous;

    if (child == prevSibling) {  // first and only child
      first = newChild;
      first.previous = newChild;
    } else {
      if (child == first) {
        first = newChild;
        // prevSibling == last, and last.next remains null
      } else {
        prevSibling.next = newChild;
      }

      if (child == last) {
        first.previous = newChild;
      } else {
        nextSibling.previous = newChild;
      }

      newChild.previous = prevSibling;
    }
    newChild.next = nextSibling;  // maybe null

    child.next = null;
    child.previous = null;
    child.parent = null;
  }
403421
function addLinkToParent(idNode, idParentNode){
    g.addLink(idParentNode, idNode, nodesToBeLinked[idNode].name);
    delete nodesToBeLinked[idNode];

    //we remove the node from childrenNodes
    var index = childrenNodes.indexOf(idNode);
    if (index > -1) {
        childrenNodes.splice(index, 1);
    }
}
675115
function push_thru( ParseNode $Node ){
		foreach( $Node->children as $Child ){
			$Node->remove( $Child );
			$this->push( $Child );
		}
		return $this->length;
	}
538671
public void addChild(final DiffNode node)
	{
		if (node == this)
		{
			throw new IllegalArgumentException("Detected attempt to add a node to itself. " +
					"This would cause inifite loops and must never happen.");
		}
		else if (node.isRootNode())
		{
			throw new IllegalArgumentException("Detected attempt to add root node as child. " +
					"This is not allowed and must be a mistake.");
		}
		else if (node.getParentNode() != null && node.getParentNode() != this)
		{
			throw new IllegalArgumentException("Detected attempt to add child node that is already the " +
					"child of another node. Adding nodes multiple times is not allowed, since it could " +
					"cause infinite loops.");
		}
		if (node.getParentNode() == null)
		{
			node.setParentNode(this);
		}
		children.put(node.getElementSelector(), node);
		if (state == State.UNTOUCHED && node.hasChanges())
		{
			state = State.CHANGED;
		}
	}
813536
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
  {

    error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);  //"replaceChild not supported!");

    return null;
  }
182844
public void removeChildNode() throws ChildNodeException {
    Node parentLast;
    Node thisLast;

    // Add this nodes children to the end of the Parents children list
    if (!isLeaf() && hasParent()) {
      parentLast = getParentNode().getFirstChild().getPrevSibling();
      thisLast = getFirstChild().getPrevSibling();

      // add the first child to the end of the parent list
      parentLast.setNextSibling(getFirstChild());

      //point the last child to the start of the parent list
      thisLast.setNextSibling(getParentNode().getFirstChild());

      // Now remove self
      getParentNode().removeChild(this);
    }
  }
1323658
@Override
	public void addChild(final ITreeNode<T> child)
	{
		if (children != null)
		{
			children.add(child);
		}
		else
		{
			children = new ArrayList<>();
			children.add(child);
		}

	}
730668
public void swapTwoChildren(GroovySourceAST t) {
        // this swaps the two child nodes, see javadoc above for explanation of implementation
        GroovySourceAST a = (GroovySourceAST) t.getFirstChild();
        GroovySourceAST b = (GroovySourceAST) a.getNextSibling();

        t.setFirstChild(b);
        a.setNextSibling(null);
        b.setNextSibling(a);
    }
304176
public void remove(int node) {
        if (node == NIL) {
            throw new IllegalArgumentException();
        }
        if (left(node) != NIL && right(node) != NIL) {
            // inner node
            final int next = next(node);
            assert next != NIL;
            swap(node, next);
        }
        assert left(node) == NIL || right(node) == NIL;

        final int parent = parent(node);
        int child = left(node);
        if (child == NIL) {
            child = right(node);
        }

        if (child == NIL) {
            // no children
            if (node == root) {
                assert size() == 1 : size();
                root = NIL;
            } else {
                if (node == left(parent)) {
                    left(parent, NIL);
                } else {
                    assert node == right(parent);
                    right(parent, NIL);
                }
            }
        } else {
            // one single child
            if (node == root) {
                assert size() == 2;
                root = child;
            } else if (node == left(parent)) {
                left(parent, child);
            } else {
                assert node == right(parent);
                right(parent, child);
            }
            parent(child, parent);
        }

        release(node);
        rebalance(parent);
    }
12743
function removeNode(node, parentNode, skipKeyedNodes) {
            if (onBeforeNodeDiscarded(node) === false) {
                return;
            }

            if (parentNode) {
                parentNode.removeChild(node);
            }

            onNodeDiscarded(node);
            walkDiscardedChildNodes(node, skipKeyedNodes);
        }
1077784
private void appendNode(Node appendNode) {
        if (currentElement==null) {
            currentDocument.appendChild(appendNode);
        } else {
            currentElement.appendChild(appendNode);
        }
    }
419608
public final void replaceFirstOrChildAfter(@Nullable Node prev, Node newChild) {
    Node target = prev == null ? first : prev.next;
    checkNotNull(target, "prev doesn't have a sibling to replace.");
    replaceChild(target, newChild);
  }
987885
public static void nodeWalker(NodeList childNodes, NodeElementParser parser) throws ParseException {
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node item = childNodes.item(i);
            String node = item.getNodeName();
            if(item.getNodeType() == Node.ELEMENT_NODE){
                parser.parse(item);
            }
            nodeWalker(item.getChildNodes(), parser);
        }
    }
1034897
function(n1, n2) {
            if (n1.swapNode) {
                n1.swapNode(n2);
            } else {
                var p = n2.parentNode;
                var s = n2.nextSibling;

                if (s == n1) {
                    p.insertBefore(n1, n2);
                } else if (n2 == n1.nextSibling) {
                    p.insertBefore(n2, n1);
                } else {
                    n1.parentNode.replaceChild(n2, n1);
                    p.insertBefore(n1, s);
                }
            }
        }
1021019
public void replaceChild(Node current, Node with) {
        double currentSplit = nodeSplits.get(current);
        int index = children.indexOf(current);
        children.remove(current);
        addChild(with, index, currentSplit);
        notifyStateChange();
    }