Program: 15901
Project: 15901
Buggy source:
private boolean adjustInsertionForRemove(HtmlShadowElement se,Component removed){
  Component old=null;
  Direction direction=inRange(se,removed);
switch (direction) {
case PREVIOUS:
    old=se._previousInsertion;
  if (old != null) {
    HtmlShadowElement previousSibling=asShadow(se.getPreviousSibling());
    if (previousSibling != null) {
      if (previousSibling._nextInsertion == old) {
        previousSibling._nextInsertion=se;
        se._previousInsertion=previousSibling;
      }
 else {
        se._previousInsertion=old.getPreviousSibling();
      }
    }
 else {
      HtmlShadowElement parentSe=asShadow(se.getParent());
      if (parentSe == null || parentSe._firstInsertion != old) {
        se._previousInsertion=old.getPreviousSibling();
      }
 else {
        se._previousInsertion=null;
      }
    }
    return true;
  }
case NEXT:
old=se._nextInsertion;
if (old != null) {
HtmlShadowElement nextSibling=asShadow(se.getNextSibling());
if (nextSibling != null) {
  if (nextSibling._previousInsertion == old) {
    nextSibling._previousInsertion=se;
    se._nextInsertion=nextSibling;
  }
 else {
    se._nextInsertion=old.getNextSibling();
  }
}
 else {
  HtmlShadowElement parentSe=asShadow(se.getParent());
  if (parentSe == null || parentSe._lastInsertion != old) {
    se._nextInsertion=old.getPreviousSibling();
  }
 else {
    se._nextInsertion=null;
  }
}
return true;
}
case IN_RANGE:
case FIRST:
case LAST:
List<HtmlShadowElement> children=se.getChildren();
if (!children.isEmpty()) {
for (Iterator<HtmlShadowElement> sit=children.iterator(); sit.hasNext(); ) {
if (adjustInsertionForRemove(sit.next(),removed)) return true;
}
}
default :
return false;
}
}

Fixed version (ground truth):
private boolean adjustInsertionForRemove(HtmlShadowElement se,Component removed){
  Component old=null;
  Direction direction=inRange(se,removed);
switch (direction) {
case PREVIOUS:
    old=se._previousInsertion;
  if (old != null) {
    HtmlShadowElement previousSibling=asShadow(se.getPreviousSibling());
    if (previousSibling != null) {
      if (previousSibling._nextInsertion == old) {
        previousSibling._nextInsertion=se;
        se._previousInsertion=previousSibling;
      }
 else {
        se._previousInsertion=old.getPreviousSibling();
      }
    }
 else {
      HtmlShadowElement parentSe=asShadow(se.getParent());
      if (parentSe == null || parentSe._firstInsertion != old) {
        se._previousInsertion=old.getPreviousSibling();
      }
 else {
        se._previousInsertion=null;
      }
    }
    return true;
  }
case NEXT:
old=se._nextInsertion;
if (old != null) {
HtmlShadowElement nextSibling=asShadow(se.getNextSibling());
if (nextSibling != null) {
  if (nextSibling._previousInsertion == old) {
    nextSibling._previousInsertion=se;
    se._nextInsertion=nextSibling;
  }
 else {
    se._nextInsertion=old.getNextSibling();
  }
}
 else {
  HtmlShadowElement parentSe=asShadow(se.getParent());
  if (parentSe == null || parentSe._lastInsertion != old) {
    se._nextInsertion=old.getPreviousSibling();
  }
 else {
    se._nextInsertion=null;
  }
}
return true;
}
case IN_RANGE:
case FIRST:
case LAST:
List<HtmlShadowElement> children=se.getChildren();
if (!children.isEmpty()) {
for (Iterator<HtmlShadowElement> sit=children.iterator(); sit.hasNext(); ) {
if (adjustInsertionForRemove(sit.next(),removed)) return true;
}
}
 else {
if (direction == Direction.FIRST) {
se.shrinkRange(se._firstInsertion,se._firstInsertion);
return true;
}
 else if (direction == Direction.LAST) {
se.shrinkRange(se._lastInsertion,se._lastInsertion);
return true;
}
}
default :
return false;
}
}