Program: 117925
Project: 117925
Buggy source:
private TreeNode addElement(TreeNode current,String currentPath,String newPath,String type,NodeType nodeType,int order){
  TreeNode temp=createModel();
  String name=newPath.substring(newPath.lastIndexOf("String_Node_Str") + 1);
  String parentPath=newPath.substring(0,newPath.lastIndexOf("String_Node_Str"));
  temp.setName(name);
  if (type == null) {
    type=XmlMapUtil.DEFAULT_DATA_TYPE;
  }
  temp.setType(type);
  temp.setNodeType(nodeType);
  if (type.equals("String_Node_Str")) {
    temp.setPattern("String_Node_Str");
  }
  if (current == null) {
    temp.setXpath(XmlMapUtil.getXPath(schemaNode.getXpath(),name,nodeType));
    return temp;
  }
  if (currentPath.equals(parentPath)) {
    temp.setXpath(XmlMapUtil.getXPath(current.getXpath(),name,nodeType));
    addChildInOrder(current,temp,order);
  }
 else {
    String[] nods=currentPath.split("String_Node_Str");
    String[] newNods=parentPath.split("String_Node_Str");
    int parentLevel=0;
    int checkLength=nods.length < newNods.length ? nods.length : newNods.length;
    for (int i=1; i < checkLength; i++) {
      if (nods[i].equals(newNods[i])) {
        parentLevel=i;
      }
    }
    TreeNode parent=current;
    for (int i=0; i < nods.length - (parentLevel + 1); i++) {
      TreeNode tmpParent=(TreeNode)parent.eContainer();
      if (tmpParent == null) {
        break;
      }
      parent=tmpParent;
    }
    if (parent != null) {
      temp.setXpath(XmlMapUtil.getXPath(parent.getXpath(),name,nodeType));
      addChildInOrder(parent,temp,order);
    }
  }
  return temp;
}

Fixed version (ground truth):
private TreeNode addElement(TreeNode current,String currentPath,String newPath,String type,String pattern,NodeType nodeType,int order){
  TreeNode temp=createModel();
  String name=newPath.substring(newPath.lastIndexOf("String_Node_Str") + 1);
  String parentPath=newPath.substring(0,newPath.lastIndexOf("String_Node_Str"));
  temp.setName(name);
  if (type == null) {
    type=XmlMapUtil.DEFAULT_DATA_TYPE;
  }
  temp.setType(type);
  temp.setNodeType(nodeType);
  if (pattern != null) {
    temp.setPattern(pattern);
  }
 else   if (type.equals("String_Node_Str")) {
    temp.setPattern("String_Node_Str");
  }
  if (current == null) {
    temp.setXpath(XmlMapUtil.getXPath(schemaNode.getXpath(),name,nodeType));
    return temp;
  }
  if (currentPath.equals(parentPath)) {
    temp.setXpath(XmlMapUtil.getXPath(current.getXpath(),name,nodeType));
    addChildInOrder(current,temp,order);
  }
 else {
    String[] nods=currentPath.split("String_Node_Str");
    String[] newNods=parentPath.split("String_Node_Str");
    int parentLevel=0;
    int checkLength=nods.length < newNods.length ? nods.length : newNods.length;
    for (int i=1; i < checkLength; i++) {
      if (nods[i].equals(newNods[i])) {
        parentLevel=i;
      }
    }
    TreeNode parent=current;
    for (int i=0; i < nods.length - (parentLevel + 1); i++) {
      TreeNode tmpParent=(TreeNode)parent.eContainer();
      if (tmpParent == null) {
        break;
      }
      parent=tmpParent;
    }
    if (parent != null) {
      temp.setXpath(XmlMapUtil.getXPath(parent.getXpath(),name,nodeType));
      addChildInOrder(parent,temp,order);
    }
  }
  return temp;
}