Program: 74553
Project: 74553
Buggy source:
/** 
 * Find the next child within the top composite entity. The child is either an atomic actor (  {@link AtomicActor}) or an opaque composite entity, one that has a director in it. If the top composite entity does not have any more child, <tt>null</tt> is returned.
 * @param top The top composite entity in which the search is performed.
 * @param indexedLists A list that is used to encode the composite entitiesvisited.
 * @param excludedEntities The atomic actor or opaque composite entitiesthat should not be returned.
 * @return The child found, or <tt>null</tt> if none.
 * @see #findFirstChild(CompositeEntity,IndexedLists,Collection)
 */
public ComponentEntity findNextChild(CompositeEntity top,IndexedLists indexedLists,Collection<Object> excludedEntities){
  if (indexedLists.isEmpty()) {
    return findFirstChild(top,indexedLists,excludedEntities);
  }
 else {
    IndexedLists.Entry entry=indexedLists.getTail();
    while (entry != null) {
      IndexedList indexedList=entry.getValue();
      List<?> entityList=indexedList.getFirst();
      for (int index=indexedList.getSecond() + 1; index < entityList.size(); index++) {
        indexedList.setSecond(index);
        ComponentEntity entity=(ComponentEntity)entityList.get(index);
        if (!excludedEntities.contains(entity)) {
          indexedLists.removeAllAfter(entry);
          if (entity instanceof AtomicActor || entity instanceof CompositeEntity && _isOpaque((CompositeEntity)entity)) {
            return entity;
          }
 else {
            CompositeEntity compositeEntity=(CompositeEntity)entity;
            ComponentEntity child=findFirstChild(compositeEntity,indexedLists,excludedEntities);
            if (child != null) {
              return child;
            }
          }
        }
      }
      entry=entry.getPrevious();
    }
    indexedLists.clear();
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Find the next child within the top composite entity. The child is either an atomic actor (  {@link AtomicActor}) or an opaque composite entity, one that has a director in it. If the top composite entity does not have any more child, <tt>null</tt> is returned.
 * @param top The top composite entity in which the search is performed.
 * @param indexedLists A list that is used to encode the composite entitiesvisited.
 * @param excludedEntities The atomic actor or opaque composite entitiesthat should not be returned.
 * @return The child found, or <tt>null</tt> if none.
 * @see #findFirstChild(CompositeEntity,IndexedLists,Collection)
 */
public NamedObj findNextChild(CompositeEntity top,IndexedLists indexedLists,Collection<Object> excludedEntities){
  if (indexedLists.isEmpty()) {
    return findFirstChild(top,indexedLists,excludedEntities);
  }
 else {
    IndexedLists.Entry entry=indexedLists.getTail();
    while (entry != null) {
      IndexedList indexedList=entry.getValue();
      List<?> objectList=indexedList.getFirst();
      for (int index=indexedList.getSecond() + 1; index < objectList.size(); index++) {
        indexedList.setSecond(index);
        NamedObj object=(NamedObj)objectList.get(index);
        indexedLists.removeAllAfter(entry);
        if (!(object instanceof CompositeEntity && !_isOpaque((CompositeEntity)object))) {
          if (!excludedEntities.contains(object)) {
            return object;
          }
        }
 else {
          CompositeEntity compositeEntity=(CompositeEntity)object;
          NamedObj child=findFirstChild(compositeEntity,indexedLists,excludedEntities);
          if (child != null) {
            return child;
          }
        }
      }
      entry=entry.getPrevious();
    }
    indexedLists.clear();
    return null;
  }
}