Program: 15982
Project: 15982
Buggy source:
/** 
 * Merge the all sub-tree into the parent's insertions, unlike  {@link #appendChild(Component)}
 */
protected void mergeSubTree(){
  List<HtmlShadowElement> children=getChildren();
  if (children == null || children.isEmpty())   return;
  if (_parent != null) {
    for (    HtmlShadowElement child : new ArrayList<HtmlShadowElement>(children)) {
      Component previous=child._previousInsertion;
      Component next=child._nextInsertion;
      _parent.insertBefore(child,this);
      if (previous != null && !(previous instanceof HtmlShadowElement)) {
        Component newPrevious=child._previousInsertion;
        setPrevInsertion(previous,newPrevious);
        setPrevInsertion(child,previous);
      }
      if (next != null && !(next instanceof HtmlShadowElement)) {
        Component newNext=child._nextInsertion;
        setPrevInsertion(newNext,next);
        setPrevInsertion(next,child);
      }
      if (_firstInsertion == child._firstInsertion)       _firstInsertion=null;
      if (_lastInsertion == child._lastInsertion)       _lastInsertion=null;
    }
  }
 else {
    for (    HtmlShadowElement child : new ArrayList<HtmlShadowElement>(children)) {
      Component previous=_previousInsertion;
      child.mergeToHost(_host);
      if (previous != null) {
        Component newPrevious=child._previousInsertion;
        if (newPrevious == null) {
          setPrevInsertion(child,previous);
        }
 else {
          setPrevInsertion(newPrevious,previous);
        }
      }
      Component newNext=child._nextInsertion;
      if (newNext == null) {
        setPrevInsertion(this,child);
      }
      if (_firstInsertion == child._firstInsertion || _firstInsertion == child._previousInsertion)       _firstInsertion=null;
      if (_lastInsertion == child._lastInsertion || _lastInsertion == child._nextInsertion)       _lastInsertion=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Merge the all sub-tree into the parent's insertions, unlike  {@link #appendChild(Component)}
 */
protected void mergeSubTree(){
  List<HtmlShadowElement> children=getChildren();
  if (children == null || children.isEmpty())   return;
  if (_parent != null) {
    for (    HtmlShadowElement child : new ArrayList<HtmlShadowElement>(children)) {
      Component previous=child._previousInsertion;
      Component next=child._nextInsertion;
      _parent.insertBefore(child,this);
      if (previous != null && !(previous instanceof HtmlShadowElement)) {
        Component newPrevious=child._previousInsertion;
        setPrevInsertion(previous,newPrevious);
        setPrevInsertion(child,previous);
      }
      if (next != null && !(next instanceof HtmlShadowElement)) {
        Component newNext=child._nextInsertion;
        setPrevInsertion(newNext,next);
        setPrevInsertion(next,child);
      }
      if (_firstInsertion == child._firstInsertion)       _firstInsertion=null;
      if (_lastInsertion == child._lastInsertion)       _lastInsertion=null;
    }
  }
 else {
    Component previous=_previousInsertion;
    for (    HtmlShadowElement child : new ArrayList<HtmlShadowElement>(children)) {
      child.mergeToHost(_host);
      if (previous != null) {
        Component newPrevious=child._previousInsertion;
        if (newPrevious == null && previous != null) {
          setPrevInsertion(child,previous);
        }
 else         if (previous != null) {
          setPrevInsertion(newPrevious,previous);
        }
        previous=null;
      }
      Component newNext=child._nextInsertion;
      if (newNext == null) {
        setPrevInsertion(this,child);
      }
      if (_firstInsertion == child._firstInsertion || _firstInsertion == child._previousInsertion)       _firstInsertion=null;
      if (_lastInsertion == child._lastInsertion || _lastInsertion == child._nextInsertion)       _lastInsertion=null;
    }
  }
}