Program: 118521
Project: 118521
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();
    createTreeNode.setOptional(foxNode.isOptional());
    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()));
    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;
    }
    String dataType=null;
    if (targetAbsolutePath != null) {
      dataType=targetAbsolutePath.get(tempXpath);
    }
    if (dataType == null) {
      dataType=foxNode.getDataType();
    }
    if (dataType != null && !"String_Node_Str".equals(dataType)) {
      if (dataType.equals("String_Node_Str")) {
        createTreeNode.setPattern("String_Node_Str");
      }
      createTreeNode.setType(dataType);
    }
 else {
      createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    }
    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);
    }
  }
}

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();
    createTreeNode.setOptional(foxNode.isOptional());
    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()));
    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;
    }
    String dataType=null;
    if (targetAbsolutePath != null) {
      dataType=targetAbsolutePath.get(tempXpath);
    }
    if (dataType == null) {
      dataType=foxNode.getDataType();
    }
    if (dataType != null && !"String_Node_Str".equals(dataType)) {
      if (dataType.equals("String_Node_Str")) {
        String datePattern=targetDatePattern.get(tempXpath);
        if (datePattern == null || "String_Node_Str".equals(datePattern)) {
          datePattern="String_Node_Str";
        }
        createTreeNode.setPattern(datePattern);
      }
      createTreeNode.setType(dataType);
    }
 else {
      createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    }
    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);
    }
  }
}