branchClone.replace(0, numChildren, cloneChildren);
branchClone.replace(0, 0, cloneChildren);
    public Element clone(Element parent, Element clonee)    {      Element clone = clonee;      // We can only handle AbstractElements here.      if (clonee instanceof BranchElement)        {          BranchElement branchEl = (BranchElement) clonee;          BranchElement branchClone =            new BranchElement(parent, branchEl.getAttributes());          // Also clone all of the children.          int numChildren = branchClone.getElementCount();          Element[] cloneChildren = new Element[numChildren];          for (int i = 0; i < numChildren; ++i)            {              cloneChildren[i] = clone(branchClone,                                       branchClone.getElement(i));            }          branchClone.replace(0, numChildren, cloneChildren);          clone = branchClone;        }      else if (clonee instanceof LeafElement)        {          clone = new LeafElement(parent, clonee.getAttributes(),                                  clonee.getStartOffset(),                                  clonee.getEndOffset());        }      return clone;    }