Program: 120463
Project: 120463
Buggy source:
public Set getChildren(Object parentElement){
  Set values=new HashSet();
  if (parentElement instanceof Message) {
    Message messParent=(Message)parentElement;
    String[] childNames=messParent.getNames();
    if (!values.isEmpty()) {
      values.clear();
    }
    for (int i=0; i < childNames.length; i++) {
      try {
        Structure[] childReps=messParent.getAll(childNames[i]);
        for (int j=0; j < childReps.length; j++) {
          if (childReps[j] instanceof Message) {
            values.add(childReps[j]);
            if (getChildren(childReps[j]).size() > 0) {
              values.addAll(getChildren(childReps[j]));
            }
          }
          if (childReps[j] instanceof Group) {
            allSegmentFromGroup.clear();
            getAllSegmentsFromGroup((Group)childReps[j]);
            if (allSegmentFromGroup.size() > 0) {
              values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
              for (              SegmentModel sm : Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0]))) {
                if (getChildren(sm).size() > 0) {
                  values.add(getChildren(sm));
                }
              }
            }
          }
          if (childReps[j] instanceof Segment) {
            SegmentModel sModel=new SegmentModel((Segment)childReps[j],messParent,i,j);
            if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
              values.add(sModel);
              if (getChildren(sModel).size() > 0) {
                values.addAll(getChildren(sModel));
              }
              if (!allSegmentsForMessage.contains(sModel)) {
                allSegmentsForMessage.add(sModel);
              }
            }
          }
        }
      }
 catch (      HL7Exception e) {
        e.printStackTrace();
      }
    }
    return values;
  }
  if (parentElement instanceof Segment) {
    values.clear();
    Segment segment=(Segment)parentElement;
    SegmentModel sm=new SegmentModel(segment,segment,0,0);
    TypeModel[] models=sm.getTypes();
    for (    TypeModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof SegmentModel) {
    SegmentModel sm=(SegmentModel)parentElement;
    TypeModel[] models=sm.getTypes();
    for (    TypeModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof TypeModel) {
    TypeModel tm=(TypeModel)parentElement;
    PrimitiveModel[] models=tm.getPrimitives();
    for (    PrimitiveModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof Group) {
    values.clear();
    Group group=(Group)parentElement;
    String[] childNames=group.getNames();
    for (int i=0; i < childNames.length; i++) {
      try {
        Structure[] childReps=group.getAll(childNames[i]);
        for (int j=0; j < childReps.length; j++) {
          if (childReps[j] instanceof Segment) {
            SegmentModel sm=new SegmentModel((Segment)childReps[j],group,i,j);
            if (sm.getTypes() != null && sm.getTypes().length > 0) {
              values.add(sm);
              if (getChildren(sm).size() > 0) {
                values.addAll(getChildren(sm));
              }
            }
          }
 else {
            values.add(childReps[j]);
            if (getChildren(childReps[j]).size() > 0) {
              values.addAll(getChildren(childReps[j]));
            }
          }
        }
      }
 catch (      HL7Exception e) {
        e.printStackTrace();
      }
    }
    return values;
  }
  return values;
}

Fixed version (ground truth):
public Set getChildren(Object parentElement){
  Set values=new HashSet();
  if (parentElement instanceof Message) {
    Message messParent=(Message)parentElement;
    String[] childNames=messParent.getNames();
    if (!values.isEmpty()) {
      values.clear();
    }
    for (int i=0; i < childNames.length; i++) {
      try {
        Structure[] childReps=messParent.getAll(childNames[i]);
        for (int j=0; j < childReps.length; j++) {
          if (childReps[j] instanceof Message) {
            values.add(childReps[j]);
            if (getChildren(childReps[j]).size() > 0) {
              values.addAll(getChildren(childReps[j]));
            }
          }
          if (childReps[j] instanceof Group) {
            values.add(childReps[j]);
            allSegmentFromGroup.clear();
            getAllSegmentsFromGroup((Group)childReps[j]);
          }
          if (childReps[j] instanceof Segment) {
            SegmentModel sModel=new SegmentModel((Segment)childReps[j],messParent,i,j);
            if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
              values.add(sModel);
              if (getChildren(sModel).size() > 0) {
                values.addAll(getChildren(sModel));
              }
              if (!allSegmentsForMessage.contains(sModel)) {
                allSegmentsForMessage.add(sModel);
              }
            }
          }
        }
      }
 catch (      HL7Exception e) {
        e.printStackTrace();
      }
    }
    return values;
  }
  if (parentElement instanceof Segment) {
    values.clear();
    Segment segment=(Segment)parentElement;
    SegmentModel sm=new SegmentModel(segment,segment,0,0);
    TypeModel[] models=sm.getTypes();
    for (    TypeModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof SegmentModel) {
    SegmentModel sm=(SegmentModel)parentElement;
    TypeModel[] models=sm.getTypes();
    for (    TypeModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof TypeModel) {
    TypeModel tm=(TypeModel)parentElement;
    PrimitiveModel[] models=tm.getPrimitives();
    for (    PrimitiveModel model : models) {
      values.add(model);
      if (getChildren(model).size() > 0) {
        values.addAll(getChildren(model));
      }
    }
    return values;
  }
  if (parentElement instanceof Group) {
    values.clear();
    Group group=(Group)parentElement;
    String[] childNames=group.getNames();
    for (int i=0; i < childNames.length; i++) {
      try {
        Structure[] childReps=group.getAll(childNames[i]);
        for (int j=0; j < childReps.length; j++) {
          if (childReps[j] instanceof Segment) {
            SegmentModel sm=new SegmentModel((Segment)childReps[j],group,i,j);
            if (sm.getTypes() != null && sm.getTypes().length > 0) {
              values.add(sm);
              if (getChildren(sm).size() > 0) {
                values.addAll(getChildren(sm));
              }
            }
          }
 else {
            values.add(childReps[j]);
            if (getChildren(childReps[j]).size() > 0) {
              values.addAll(getChildren(childReps[j]));
            }
          }
        }
      }
 catch (      HL7Exception e) {
        e.printStackTrace();
      }
    }
    return values;
  }
  return values;
}