code: public void replaceChild(int index, N newChild) {
      checkNotNull(newChild);
      tryRemoveFromOldParent(newChild);
      N oldChild = children.set(index, newChild);
      oldChild.setParent(null);
      newChild.setParent(master);
    }
docs: Replaces the child at the given index with the given new child.
  
  @param index The index of the child to replace.
  @param newChild The new child.