Program: 74499
Project: 74499
Buggy source:
private void _removeObjects(CompositeEntity host) throws TransformationException {
  CompositeEntity replacement=(CompositeEntity)_replacementToHost.getKey(host);
  Collection<?> children=GTTools.getChildren(host,false,false,true,true);
  Map<NamedObj,Boolean> childrenToRemove=new HashMap<NamedObj,Boolean>();
  Set<NamedObj> newChildren=new HashSet<NamedObj>();
  while (!children.isEmpty()) {
    childrenToRemove.clear();
    for (    Object childObject : children) {
      NamedObj child=(NamedObj)childObject;
      NamedObj replacementChild=(NamedObj)_replacementToHost.getKey(child);
      NamedObj patternChild=(NamedObj)_matchResult.getKey(child);
      if (replacementChild == null && patternChild != null) {
        Boolean shallowRemoval=patternChild instanceof CompositeEntity ? Boolean.TRUE : Boolean.FALSE;
        childrenToRemove.put(child,shallowRemoval);
      }
 else       if (replacementChild != null && replacementChild.getContainer() != replacement) {
        Boolean shallowRemoval=replacementChild instanceof CompositeEntity ? Boolean.TRUE : Boolean.FALSE;
        childrenToRemove.put(child,shallowRemoval);
      }
    }
    newChildren.clear();
    for (    Map.Entry<NamedObj,Boolean> entry : childrenToRemove.entrySet()) {
      NamedObj child=entry.getKey();
      Set<NamedObj> newlyAddedChildren=_removeObject(child,entry.getValue());
      if (newlyAddedChildren != null) {
        newChildren.addAll(newlyAddedChildren);
      }
    }
    children=newChildren;
  }
  for (  Object compositeChild : host.entityList(CompositeEntity.class)) {
    _removeObjects((CompositeEntity)compositeChild);
  }
}

Fixed version (ground truth):
private void _removeObjects(CompositeEntity host) throws TransformationException {
  NamedObj replacement=_replacementToHost.getKey(host);
  Collection<?> children=GTTools.getChildren(host,false,false,true,true);
  Map<NamedObj,Boolean> childrenToRemove=new HashMap<NamedObj,Boolean>();
  Set<NamedObj> newChildren=new HashSet<NamedObj>();
  while (!children.isEmpty()) {
    childrenToRemove.clear();
    for (    Object childObject : children) {
      NamedObj child=(NamedObj)childObject;
      NamedObj replacementChild=(NamedObj)_replacementToHost.getKey(child);
      NamedObj patternChild=(NamedObj)_matchResult.getKey(child);
      if (replacementChild == null && patternChild != null) {
        Boolean shallowRemoval=patternChild instanceof CompositeEntity ? Boolean.TRUE : Boolean.FALSE;
        childrenToRemove.put(child,shallowRemoval);
      }
 else       if (replacementChild != null && replacementChild.getContainer() != replacement) {
        Boolean shallowRemoval=replacementChild instanceof CompositeEntity ? Boolean.TRUE : Boolean.FALSE;
        childrenToRemove.put(child,shallowRemoval);
      }
    }
    newChildren.clear();
    for (    Map.Entry<NamedObj,Boolean> entry : childrenToRemove.entrySet()) {
      NamedObj child=entry.getKey();
      Set<NamedObj> newlyAddedChildren=_removeObject(child,entry.getValue());
      if (newlyAddedChildren != null) {
        newChildren.addAll(newlyAddedChildren);
      }
    }
    children=newChildren;
  }
  for (  Object compositeChild : host.entityList(CompositeEntity.class)) {
    _removeObjects((CompositeEntity)compositeChild);
  }
}