Program: 119904
Project: 119904
Buggy source:
private void initXmlTreeData(List schemaList,List<HL7FileNode> root,List<HL7TreeNode> list){
  if (hl7ui != null) {
    if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
      ((HL7OutputManager)hl7ui.gethl7Manager()).getContents().clear();
    }
  }
  for (  Object obj : schemaList) {
    List<HL7TreeNode> treeNodes=null;
    HL7TreeNode rootNode=null;
    HL7TreeNode current=null;
    HL7TreeNode temp=null;
    HL7TreeNode mainNode=null;
    String mainPath=null;
    String currentPath=null;
    String defaultValue=null;
    int nodeOrder=0;
    boolean haveOrder=true;
    String schemaId=hl7Util.getLabel(obj,true) + "String_Node_Str";
    if (hl7ui != null) {
      if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
        treeNodes=((HL7OutputManager)hl7ui.gethl7Manager()).getTreeData(hl7Util.getLabel(obj,true));
      }
    }
    if (treeNodes == null) {
      treeNodes=new ArrayList<HL7TreeNode>();
    }
    for (int i=0; i < root.size(); i++) {
      HL7FileNode node=(HL7FileNode)root.get(i);
      String newPath=node.getFilePath();
      defaultValue=node.getDefaultValue();
      String columnName=node.getRelatedColumn();
      String orderValue=String.valueOf(node.getOrder());
      if (orderValue == null || "String_Node_Str".equals(orderValue)) {
        haveOrder=false;
      }
      if (haveOrder) {
        nodeOrder=node.getOrder();
      }
      String flag=columnName + "String_Node_Str";
      if (columnName != null && columnName.length() > 0 && !flag.startsWith(schemaId)) {
        continue;
      }
      if (node.getAttribute().equals("String_Node_Str")) {
        temp=new Attribute(newPath);
        temp.setDefaultValue(defaultValue);
        temp.setAttribute(true);
        current.addChild(temp);
      }
 else       if (node.getAttribute().equals("String_Node_Str")) {
        temp=new NameSpaceNode(newPath);
        temp.setDefaultValue(defaultValue);
        temp.setNameSpace(true);
        current.addChild(temp);
      }
 else {
        temp=this.addElement(current,currentPath,newPath,defaultValue);
        if (rootNode == null) {
          rootNode=temp;
        }
        if (node.getAttribute().equals("String_Node_Str")) {
          temp.setMain(true);
          mainNode=temp;
          mainPath=newPath;
        }
        current=temp;
        currentPath=newPath;
      }
      if (haveOrder) {
        temp.setOrder(nodeOrder);
      }
      temp.setRow(hl7Util.getLabel(obj,true));
      if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
        columnName=columnName.replace(schemaId,"String_Node_Str");
      }
    }
    current=mainNode;
    currentPath=mainPath;
    boolean isFirst=true;
    current=mainNode;
    currentPath=mainPath;
    isFirst=true;
    if (rootNode == null) {
      rootNode=new Element("String_Node_Str");
    }
    if (haveOrder) {
      orderNode(rootNode);
    }
    list.add(rootNode);
    rootNode.setRow(hl7Util.getLabel(obj,true));
    treeNodes.clear();
    treeNodes.add(rootNode);
    if (hl7ui != null) {
      if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
        ((HL7OutputManager)hl7ui.gethl7Manager()).getContents().put(hl7Util.getLabel(obj,true),treeNodes);
      }
    }
 else     if (form != null) {
      for (      HL7TreeNode hl7Node : treeNodes) {
        form.getContents().put(hl7Util.getLabel(obj,true),hl7Node);
      }
    }
  }
}

Fixed version (ground truth):
private void initXmlTreeData(List<String> schemaList,List<HL7FileNode> root,List<HL7TreeNode> treeData){
  Map<String,HL7TreeNode> mapNodes=new HashMap<String,HL7TreeNode>();
  if (hl7ui != null) {
    if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
      ((HL7OutputManager)hl7ui.gethl7Manager()).getContents().clear();
    }
  }
  HL7TreeNode rootNode=null;
  for (  String rowName : schemaList) {
    HL7TreeNode current=null;
    HL7TreeNode temp=null;
    HL7TreeNode mainNode=null;
    String mainPath=null;
    String currentPath=null;
    String defaultValue=null;
    int nodeOrder=0;
    boolean haveOrder=true;
    String schemaId=rowName + "String_Node_Str";
    for (int i=0; i < root.size(); i++) {
      HL7FileNode node=(HL7FileNode)root.get(i);
      String newPath=node.getFilePath();
      defaultValue=node.getDefaultValue();
      String columnName=node.getRelatedColumn();
      String orderValue=String.valueOf(node.getOrder());
      if (orderValue == null || "String_Node_Str".equals(orderValue)) {
        haveOrder=false;
      }
      if (haveOrder) {
        nodeOrder=node.getOrder();
      }
      String flag=columnName + "String_Node_Str";
      if (columnName != null && columnName.length() > 0 && !flag.startsWith(schemaId)) {
        continue;
      }
      if (node.getAttribute().equals("String_Node_Str")) {
        temp=new Attribute(newPath);
        temp.setDefaultValue(defaultValue);
        temp.setAttribute(true);
        current.addChild(temp);
      }
 else       if (node.getAttribute().equals("String_Node_Str")) {
        temp=new NameSpaceNode(newPath);
        temp.setDefaultValue(defaultValue);
        temp.setNameSpace(true);
        current.addChild(temp);
      }
 else {
        temp=this.addElement(current,currentPath,newPath,defaultValue,mapNodes);
        if (rootNode == null) {
          rootNode=temp;
        }
        if (node.getAttribute().equals("String_Node_Str")) {
          temp.setMain(true);
          mainNode=temp;
          mainPath=newPath;
        }
        current=temp;
        currentPath=newPath;
      }
      if (haveOrder) {
        temp.setOrder(nodeOrder);
      }
      if (columnName != null && columnName.length() > 0) {
        temp.setRow(rowName);
      }
      if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
        columnName=columnName.replace(schemaId,"String_Node_Str");
      }
    }
    if (rootNode == null) {
      rootNode=new Element("String_Node_Str");
    }
    if (haveOrder) {
      orderNode(rootNode);
    }
  }
  if (rootNode != null) {
    treeData.add(rootNode);
  }
  if (hl7ui != null) {
    if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
      ((HL7OutputManager)hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(),treeData);
    }
  }
 else   if (form != null) {
    for (    HL7TreeNode hl7Node : treeData) {
      form.getContents().put(rootNode.getColumnLabel(),hl7Node);
    }
  }
}