Program: 12264
Project: 12264
Buggy source:
private AbstractStatement haveRecursivelyTheSameParent(List<AbstractStatement> list){
  Map<AbstractStatement,Integer> depthOfNestingMap=new LinkedHashMap<AbstractStatement,Integer>();
  for (  AbstractStatement statement : list) {
    int depthOfNesting=0;
    AbstractStatement parentStatement=statement.getParent();
    while (parentStatement != null) {
      parentStatement=parentStatement.getParent();
      depthOfNesting++;
    }
    depthOfNestingMap.put(statement,depthOfNesting);
  }
  TreeSet<Integer> depths=new TreeSet<Integer>();
  for (  Integer depth : depthOfNestingMap.values()) {
    depths.add(depth);
  }
  int minimumDepthOfNesting=depths.first();
  if (minimumDepthOfNesting == 1) {
    return null;
  }
 else {
    for (    AbstractStatement statement : depthOfNestingMap.keySet()) {
      int depth=depthOfNestingMap.get(statement);
      if (depth > minimumDepthOfNesting) {
        AbstractStatement parentStatement=statement;
        for (int i=0; i < depth - minimumDepthOfNesting; i++) {
          parentStatement=parentStatement.getParent();
        }
        int index=list.indexOf(statement);
        list.remove(index);
        list.add(index,parentStatement);
      }
    }
  }
  List<AbstractStatement> parentStatements=new ArrayList<AbstractStatement>();
  for (  AbstractStatement statement : list) {
    parentStatements.add(statement.getParent());
  }
  AbstractStatement parentStatement=parentStatements.get(0);
  for (int i=1; i < parentStatements.size(); i++) {
    if (!parentStatement.equals(parentStatements.get(i))) {
      return haveRecursivelyTheSameParent(parentStatements);
    }
  }
  if (parentStatement.getParent() != null)   return parentStatement;
 else   return null;
}

Fixed version (ground truth):
private CompositeStatementObject haveRecursivelyTheSameParent(List<AbstractStatement> list){
  List<AbstractStatement> copiedList=new ArrayList<AbstractStatement>(list);
  Map<AbstractStatement,Integer> depthOfNestingMap=new LinkedHashMap<AbstractStatement,Integer>();
  for (  AbstractStatement statement : copiedList) {
    int depthOfNesting=0;
    AbstractStatement parentStatement=statement.getParent();
    while (parentStatement != null) {
      parentStatement=parentStatement.getParent();
      depthOfNesting++;
    }
    depthOfNestingMap.put(statement,depthOfNesting);
  }
  TreeSet<Integer> depths=new TreeSet<Integer>();
  for (  Integer depth : depthOfNestingMap.values()) {
    depths.add(depth);
  }
  int minimumDepthOfNesting=depths.first();
  if (minimumDepthOfNesting == 1) {
    return null;
  }
 else {
    for (    AbstractStatement statement : depthOfNestingMap.keySet()) {
      int depth=depthOfNestingMap.get(statement);
      if (depth > minimumDepthOfNesting) {
        AbstractStatement parentStatement=statement;
        for (int i=0; i < depth - minimumDepthOfNesting; i++) {
          parentStatement=parentStatement.getParent();
        }
        int index=copiedList.indexOf(statement);
        copiedList.remove(index);
        copiedList.add(index,parentStatement);
      }
    }
  }
  List<AbstractStatement> parentStatements=new ArrayList<AbstractStatement>();
  for (  AbstractStatement statement : copiedList) {
    parentStatements.add(statement.getParent());
  }
  AbstractStatement parentStatement=parentStatements.get(0);
  for (int i=1; i < parentStatements.size(); i++) {
    if (!parentStatement.equals(parentStatements.get(i))) {
      return haveRecursivelyTheSameParent(parentStatements);
    }
  }
  if (parentStatement.getParent() != null)   return (CompositeStatementObject)parentStatement;
 else   return null;
}