Program: 123812
Project: 123812
Buggy source:
private void prepareEmfTree(List<FOXTreeNode> list,TreeNode parent,boolean ignoreMapped){
  if (list == null || list.isEmpty()) {
    return;
  }
  String xPath=parent.getXpath();
  TreeNode realParentNode=parent;
  if (parent.isSubstitution() || parent.isChoice()) {
    realParentNode=XmlMapUtil.getRealParentNode(parent);
    if (realParentNode != null) {
      xPath=realParentNode.getXpath();
    }
  }
  for (  FOXTreeNode foxNode : list) {
    TreeNode createTreeNode=createModel();
    String label=foxNode.getLabel();
    createTreeNode.setName(label);
    if (foxNode instanceof Element) {
      createTreeNode.setNodeType(NodeType.ELEMENT);
      if (foxNode.isChoice()) {
        createTreeNode.setChoice(foxNode.isChoice());
      }
 else       if (foxNode.isSubstitution()) {
        createTreeNode.setSubstitution(foxNode.isSubstitution());
      }
    }
 else     if (foxNode instanceof Attribute) {
      createTreeNode.setNodeType(NodeType.ATTRIBUT);
    }
 else     if (foxNode instanceof NameSpaceNode) {
      createTreeNode.setNodeType(NodeType.NAME_SPACE);
      createTreeNode.setDefaultValue(foxNode.getDefaultValue());
      if (createTreeNode.getName() == null || createTreeNode.getName().equals("String_Node_Str")) {
        createTreeNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
      }
    }
    createTreeNode.setXpath(XmlMapUtil.getXPath(xPath,label,createTreeNode.getNodeType()));
    if (foxNode.getDataType() != null && "String_Node_Str".equals(foxNode.getDataType())) {
      createTreeNode.setType(foxNode.getDataType());
    }
 else {
      createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    }
    String tempXpath=createTreeNode.getXpath().substring(schemaNode.getXpath().length() + 1);
    if (createTreeNode.isChoice() || createTreeNode.isSubstitution()) {
      if (!isMappedChoiceSubs(foxNode,xPath)) {
        continue;
      }
    }
 else     if (tempXpath.equals(absoluteXPathQuery)) {
      createTreeNode.setLoop(true);
      createTreeNode.setOptional(foxNode.isOptional());
    }
 else     if (!isMappedChild(tempXpath) && !ignoreMapped) {
      continue;
    }
    parent.getChildren().add(createTreeNode);
    if (createTreeNode.isLoop()) {
      XmlMapUtil.upsetMainNode(createTreeNode);
    }
    if (foxNode.getChildren() != null && !foxNode.getChildren().isEmpty()) {
      prepareEmfTree(foxNode.getChildren(),createTreeNode,ignoreMapped);
    }
  }
}

Fixed version (ground truth):
private void prepareEmfTree(List<FOXTreeNode> list,TreeNode parent,boolean ignoreMapped){
  if (list == null || list.isEmpty()) {
    return;
  }
  String xPath=parent.getXpath();
  TreeNode realParentNode=parent;
  if (parent.isSubstitution() || parent.isChoice()) {
    realParentNode=XmlMapUtil.getRealParentNode(parent);
    if (realParentNode != null) {
      xPath=realParentNode.getXpath();
    }
  }
  for (  FOXTreeNode foxNode : list) {
    TreeNode createTreeNode=createModel();
    String label=foxNode.getLabel();
    createTreeNode.setName(label);
    if (foxNode instanceof Element) {
      createTreeNode.setNodeType(NodeType.ELEMENT);
      if (foxNode.isChoice()) {
        createTreeNode.setChoice(foxNode.isChoice());
      }
 else       if (foxNode.isSubstitution()) {
        createTreeNode.setSubstitution(foxNode.isSubstitution());
      }
    }
 else     if (foxNode instanceof Attribute) {
      createTreeNode.setNodeType(NodeType.ATTRIBUT);
    }
 else     if (foxNode instanceof NameSpaceNode) {
      createTreeNode.setNodeType(NodeType.NAME_SPACE);
      createTreeNode.setDefaultValue(foxNode.getDefaultValue());
      if (createTreeNode.getName() == null || createTreeNode.getName().equals("String_Node_Str")) {
        createTreeNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
      }
    }
    createTreeNode.setXpath(XmlMapUtil.getXPath(xPath,label,createTreeNode.getNodeType()));
    if (foxNode.getDataType() != null && "String_Node_Str".equals(foxNode.getDataType())) {
      createTreeNode.setType(foxNode.getDataType());
    }
 else {
      createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    }
    String tempXpath=createTreeNode.getXpath().substring(schemaNode.getXpath().length() + 1);
    if (createTreeNode.isChoice() || createTreeNode.isSubstitution()) {
      if (!isMappedChoiceSubs(foxNode,xPath)) {
        continue;
      }
    }
 else     if (!ignoreMapped && !isMappedChild(tempXpath)) {
      continue;
    }
    if (tempXpath.equals(absoluteXPathQuery)) {
      createTreeNode.setLoop(true);
      createTreeNode.setOptional(foxNode.isOptional());
      loopNode=createTreeNode;
    }
    parent.getChildren().add(createTreeNode);
    if (createTreeNode.isLoop()) {
      XmlMapUtil.upsetMainNode(createTreeNode);
    }
    if (foxNode.getChildren() != null && !foxNode.getChildren().isEmpty()) {
      prepareEmfTree(foxNode.getChildren(),createTreeNode,ignoreMapped);
    }
  }
}