Program: 74554
Project: 74554
Buggy source:
/** 
 * Find the first 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 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 #findNextChild(CompositeEntity,IndexedLists,Collection)
 */
public ComponentEntity findFirstChild(CompositeEntity top,IndexedLists indexedLists,Collection<Object> excludedEntities){
  List<?> entities=top.entityList(ComponentEntity.class);
  if (!entities.isEmpty()) {
    int i=0;
    IndexedList currentList=new IndexedList(entities,0);
    indexedLists.add(currentList);
    IndexedLists.Entry currentListEntry=indexedLists.getTail();
    for (    Object entityObject : entities) {
      currentList.setSecond(i);
      if (entityObject instanceof AtomicActor || entityObject instanceof CompositeEntity && _isOpaque((CompositeEntity)entityObject)) {
        if (!excludedEntities.contains(entityObject)) {
          return (ComponentEntity)entityObject;
        }
      }
 else {
        CompositeEntity compositeEntity=(CompositeEntity)entityObject;
        ComponentEntity child=findFirstChild(compositeEntity,indexedLists,excludedEntities);
        if (child != null && !excludedEntities.contains(child)) {
          return child;
        }
      }
      i++;
    }
    currentListEntry.remove();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Find the first 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 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 #findNextChild(CompositeEntity,IndexedLists,Collection)
 */
public NamedObj findFirstChild(CompositeEntity top,IndexedLists indexedLists,Collection<Object> excludedEntities){
  List<?> entities=top.entityList(ComponentEntity.class);
  if (!entities.isEmpty()) {
    int i=0;
    IndexedList currentList=new IndexedList(entities,0);
    indexedLists.add(currentList);
    IndexedLists.Entry currentListEntry=indexedLists.getTail();
    for (    Object entityObject : entities) {
      currentList.setSecond(i);
      if (!(entityObject instanceof CompositeEntity && !_isOpaque((CompositeEntity)entityObject))) {
        if (!excludedEntities.contains(entityObject)) {
          return (NamedObj)entityObject;
        }
      }
 else {
        CompositeEntity compositeEntity=(CompositeEntity)entityObject;
        NamedObj child=findFirstChild(compositeEntity,indexedLists,excludedEntities);
        if (child != null && !excludedEntities.contains(child)) {
          return child;
        }
      }
      i++;
    }
    currentListEntry.remove();
  }
  return null;
}