Removes {@code oldChild} and adds {@code newChild} in its place. This
is not atomic.
504129
public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
        int index = ((LeafNodeImpl) oldChild).index;
        removeChild(oldChild);
        insertChildAt(newChild, index);
        return oldChild;
    }
1214326
def replaceChild(self, newchild, oldchild):
		
		# .index() would use compare-by-value, we want
		# compare-by-id because we want to find the exact object,
		# not something equivalent to it.
		for i, childNode in enumerate(self.childNodes):
			if childNode is oldchild:
				self.childNodes[i].parentNode = None
				self.childNodes[i] = newchild
				newchild.parentNode = self
				self._verifyChildren(i)
				return newchild
		raise ValueError(oldchild)
1165551
public synchronized boolean addChild(Node child) {
    if (child.parent != null) {
      throw new IllegalArgumentException(
          "The child is already under another node:" + child.parent);
    }
    checkChildren();
    boolean retval = children.add(child);
    if (retval) child.parent = this;
    return retval;
  }
444664
public boolean setFirstChild(N newChild) {
		final N oldChild = this.nNorthWest;
		if (oldChild == newChild) {
			return false;
		}

		if (oldChild != null) {
			oldChild.setParentNodeReference(null, true);
			--this.notNullChildCount;
			firePropertyChildRemoved(0, oldChild);
		}

		if (newChild != null) {
			final N oldParent = newChild.getParentNode();
			if (oldParent != this) {
				newChild.removeFromParent();
			}
		}

		this.nNorthWest = newChild;

		if (newChild != null) {
			newChild.setParentNodeReference(toN(), true);
			++this.notNullChildCount;
			firePropertyChildAdded(0, newChild);
		}

		return true;
	}
309735
private void addExtraChild(Object[] child, Object upperBound)
    {
        ensureRoom(buildKeyPosition + 1);
        buildKeys[buildKeyPosition++] = upperBound;
        buildChildren[buildChildPosition++] = child;
    }
1082669
public void removeChild(TreeElement child)
    {

        if (child == null || _children == null)
            return;

        int size = _children.size();
        int removeIndex = -1;
        for (int i = 0; i < size; i++) {
            if (child == (TreeElement) _children.get(i)) {
                _children.remove(i);
                child.setParent(null);
                removeIndex = i;
                break;
            }
        }
        if (removeIndex >= 0) {
            size = _children.size();
            for (int i = removeIndex; i < size; i++) {
                TreeElement thisChild = (TreeElement) _children.get(i);
                thisChild.updateName(this, i);
            }
        }
    }
8429
function replace(oldNode, newNode){
    return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
  }
704648
@SuppressWarnings({"unchecked"})
	public L add(N newChild, Kind newChildKind) {
		getAst().setChanged();
		L n = getAst().buildTree(newChild, newChildKind);
		if (n == null) return null;
		n.parent = (L) this;
		children = children.append(n);
		return n;
	}
469168
public void addLastChild( AstNode child ) {
        assert child != null;
        this.children.addLast(child);
        child.removeFromParent();
        child.parent = this;
    }
64505
def remove(self, child):
        """"""
        if not isinstance(child, AbstractElement):
            raise ValueError("Expected AbstractElement, got " + str(type(child)))
        if child.parent == self:
            child.parent = None
        self.data.remove(child)
        #delete from index
        if child.id and self.doc and child.id in self.doc.index:
            del self.doc.index[child.id]
793280
protected void addChild(ElementBase child, boolean doEvent) {
        if (!child.canAcceptParent(this)) {
            CWFException.raise(child.rejectReason);
        }
        
        if (!canAcceptChild(child)) {
            CWFException.raise(rejectReason);
        }
        
        if (doEvent) {
            beforeAddChild(child);
        }
        
        if (child.getParent() != null) {
            child.getParent().removeChild(child, false);
        }
        
        children.add(child);
        child.updateParent(this);
        
        if (doEvent) {
            afterAddChild(child);
        }
    }
1014590
public static <T extends MutableTreeNode<T>> void removeChild(T parent, T child) {
        checkArgNotNull(parent, "parent");
        int index = parent.getChildren().indexOf(child);
        checkElementIndex(index, parent.getChildren().size());
        parent.removeChild(index);
    }
673655
public void extractChild( AstNode child ) {
        if (child.getChildCount() == 0) {
            removeChild(child);
        } else {
            AstNode grandChild = child.getFirstChild();
            replaceChild(child, grandChild);
        }
    }
1013675
public void removeChild(ElementBase child, boolean destroy) {
        if (!children.contains(child)) {
            return;
        }
        
        boolean isLocked = child.isLocked() || child.getDefinition().isInternal();
        
        if (destroy) {
            child.removeChildren();
            
            if (!isLocked) {
                child.destroy();
            }
        }
        
        if (!isLocked) {
            beforeRemoveChild(child);
            children.remove(child);
            child.updateParent(null);
            afterRemoveChild(child);
        }
    }
236136
public void replaceItem(@NonNull final T oldObject, @NonNull final T newObject) {
        synchronized (mLock) {
            final int position = getPosition(oldObject);
            if (position == -1) {
                // not found, don't replace
                return;
            }

            mObjects.remove(position);
            mObjects.add(position, newObject);

            if (isItemTheSame(oldObject, newObject)) {
                if (isContentTheSame(oldObject, newObject)) {
                    // visible content hasn't changed, don't notify
                    return;
                }

                // item with same stable id has changed
                notifyItemChanged(position, newObject);
            } else {
                // item replaced with another one with a different id
                notifyItemRemoved(position);
                notifyItemInserted(position);
            }
        }
    }
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);
    }
  }
1349399
private void addOnlyChildElements() {
		for (Node node : nodes) {
			Index index = helper.getIndexInParent(node, false);
			if (index.size==1)
				result.add(node);
		}
	}