code: public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
          int index = ((LeafNodeImpl) oldChild).index;
          removeChild(oldChild);
          insertChildAt(newChild, index);
          return oldChild;
      }
docs: Removes {@code oldChild} and adds {@code newChild} in its place. This
  is not atomic.