Program: 147556
Project: 147556
Buggy source:
public static Object getParent(Object son){
  if (!((son instanceof XSDElementDeclaration) || (son instanceof XSDParticle))) {
    return null;
  }
  XSDElementDeclaration elem=null;
  if (son instanceof XSDParticle) {
    elem=(XSDElementDeclaration)((XSDParticle)son).getContent();
  }
 else   if (son instanceof XSDElementDeclaration) {
    elem=(XSDElementDeclaration)son;
  }
  if (elem == null || elem.getSchema() == null) {
    return null;
  }
  EList<XSDSchemaContent> parentList=elem.getSchema().getContents();
  ArrayList<Object> list=new ArrayList<Object>();
  for (  XSDSchemaContent top : parentList) {
    list.clear();
    if (!(top instanceof XSDElementDeclaration) && !(top instanceof XSDComplexTypeDefinition)) {
      continue;
    }
    if (top instanceof XSDElementDeclaration) {
      XSDElementDeclaration decl=(XSDElementDeclaration)top;
      if (decl == son) {
        return decl;
      }
      if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)decl.getTypeDefinition();
        if (type.getContent() instanceof XSDParticle) {
          XSDParticle particle=(XSDParticle)type.getContent();
          if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group=(XSDModelGroup)particle.getTerm();
            EList<XSDParticle> elist=group.getContents();
            for (            XSDParticle pt : elist) {
              if (pt.getContent() instanceof XSDElementDeclaration) {
                if (((XSDElementDeclaration)pt.getContent()) == elem) {
                  return decl;
                }
              }
              Set<XSDConcreteComponent> complexTypes=new HashSet<XSDConcreteComponent>();
              XSDElementDeclaration spec=findOutSpecialSonElement((XSDElementDeclaration)pt.getContent(),elem,complexTypes);
              if (spec != null) {
                return spec;
              }
            }
          }
        }
      }
    }
 else {
      XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)top;
      if (type.getContent() instanceof XSDParticle) {
        XSDParticle particle=(XSDParticle)type.getContent();
        if (particle.getTerm() instanceof XSDModelGroup) {
          XSDModelGroup group=(XSDModelGroup)particle.getTerm();
          EList<XSDParticle> elist=group.getContents();
          for (          XSDParticle pt : elist) {
            if (pt.getContent() instanceof XSDElementDeclaration) {
              if (((XSDElementDeclaration)pt.getContent()) == elem) {
                return top;
              }
            }
            if (pt.getContent() instanceof XSDElementDeclaration) {
              Set<XSDConcreteComponent> complexTypes=new HashSet<XSDConcreteComponent>();
              XSDElementDeclaration spec=findOutSpecialSonElement((XSDElementDeclaration)pt.getContent(),elem,complexTypes);
              if (spec != null) {
                return spec;
              }
            }
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public static Object getParent(Object son){
  if (!((son instanceof XSDElementDeclaration) || (son instanceof XSDParticle))) {
    return null;
  }
  XSDElementDeclaration elem=null;
  if (son instanceof XSDParticle) {
    elem=(XSDElementDeclaration)((XSDParticle)son).getContent();
  }
 else   if (son instanceof XSDElementDeclaration) {
    elem=(XSDElementDeclaration)son;
  }
  if (elem == null || elem.getSchema() == null) {
    return null;
  }
  EList<XSDSchemaContent> parentList=elem.getSchema().getContents();
  for (  XSDSchemaContent top : parentList) {
    if (!(top instanceof XSDElementDeclaration) && !(top instanceof XSDComplexTypeDefinition)) {
      continue;
    }
    if (top instanceof XSDElementDeclaration) {
      XSDElementDeclaration decl=(XSDElementDeclaration)top;
      if (decl == son) {
        return decl;
      }
      if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)decl.getTypeDefinition();
        if (type.getContent() instanceof XSDParticle) {
          XSDParticle particle=(XSDParticle)type.getContent();
          if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group=(XSDModelGroup)particle.getTerm();
            EList<XSDParticle> elist=group.getContents();
            for (            XSDParticle pt : elist) {
              if (pt.getContent() instanceof XSDElementDeclaration) {
                if (((XSDElementDeclaration)pt.getContent()) == elem) {
                  return decl;
                }
              }
              Set<XSDConcreteComponent> complexTypes=new HashSet<XSDConcreteComponent>();
              XSDElementDeclaration spec=findOutSpecialSonElement((XSDElementDeclaration)pt.getContent(),elem,complexTypes);
              if (spec != null) {
                return spec;
              }
            }
          }
        }
      }
    }
 else {
      XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)top;
      if (type.getContent() instanceof XSDParticle) {
        XSDParticle particle=(XSDParticle)type.getContent();
        if (particle.getTerm() instanceof XSDModelGroup) {
          XSDModelGroup group=(XSDModelGroup)particle.getTerm();
          EList<XSDParticle> elist=group.getContents();
          for (          XSDParticle pt : elist) {
            if (pt.getContent() instanceof XSDElementDeclaration) {
              if (((XSDElementDeclaration)pt.getContent()) == elem) {
                return top;
              }
            }
            if (pt.getContent() instanceof XSDElementDeclaration) {
              Set<XSDConcreteComponent> complexTypes=new HashSet<XSDConcreteComponent>();
              XSDElementDeclaration spec=findOutSpecialSonElement((XSDElementDeclaration)pt.getContent(),elem,complexTypes);
              if (spec != null) {
                return spec;
              }
            }
          }
        }
      }
    }
  }
  return null;
}