Program: 128271
Project: 128271
Buggy source:
public static FOXTreeNode cloneATreeNode(ATreeNode treeNode,String currentPath){
  FOXTreeNode node=null;
  if (treeNode.getType() == ATreeNode.ATTRIBUTE_TYPE) {
    node=new Attribute();
  }
 else {
    node=new Element();
  }
  if (treeNode.getType() == ATreeNode.NAMESPACE_TYPE) {
    node=new NameSpaceNode();
    node.setLabel(treeNode.getDataType());
    node.setDefaultValue((String)treeNode.getValue());
  }
 else {
    node.setLabel(treeNode.getValue().toString());
    node.setChoice(treeNode.isChoice());
    node.setSubstitution(treeNode.isSubstitution());
    node.setOptional(treeNode.isOptional());
    node.getUniqueNames().clear();
    node.getUniqueNames().addAll(treeNode.getUniqueNames());
  }
  MappingTypeRetriever retriever=MetadataTalendType.getMappingTypeRetriever("String_Node_Str");
  String originalDataType=treeNode.getOriginalDataType();
  if (originalDataType != null && !originalDataType.startsWith("String_Node_Str")) {
    originalDataType="String_Node_Str" + originalDataType;
  }
  node.setDataType(retriever.getDefaultSelectedTalendType(originalDataType));
  Object[] children=treeNode.getChildren();
  if (children != null) {
    for (int i=0; i < children.length; i++) {
      if (children[i] instanceof ATreeNode) {
        ATreeNode child=(ATreeNode)children[i];
        String newPath=currentPath + "String_Node_Str";
        if (child.getValue() instanceof String) {
          String elementName=(String)child.getValue();
          if (currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
            continue;
          }
          newPath+=elementName;
        }
 else {
          newPath+="String_Node_Str";
        }
        FOXTreeNode foxChild=cloneATreeNode(child,newPath);
        node.addChild(foxChild);
      }
    }
  }
  return node;
}

Fixed version (ground truth):
public static FOXTreeNode cloneATreeNode(ATreeNode treeNode,String currentPath){
  FOXTreeNode node=null;
  if (treeNode.getType() == ATreeNode.ATTRIBUTE_TYPE) {
    node=new Attribute();
  }
 else {
    node=new Element();
  }
  if (treeNode.getType() == ATreeNode.NAMESPACE_TYPE) {
    node=new NameSpaceNode();
    node.setLabel(treeNode.getDataType());
    node.setDefaultValue((String)treeNode.getValue());
  }
 else {
    node.setLabel(treeNode.getValue().toString());
    node.setChoice(treeNode.isChoice());
    node.setSubstitution(treeNode.isSubstitution());
    node.setOptional(treeNode.isOptional());
    node.getUniqueNames().clear();
    node.getUniqueNames().addAll(treeNode.getUniqueNames());
  }
  MappingTypeRetriever retriever=MetadataTalendType.getMappingTypeRetriever("String_Node_Str");
  String originalDataType=treeNode.getOriginalDataType();
  if (originalDataType != null && !originalDataType.startsWith("String_Node_Str")) {
    originalDataType="String_Node_Str" + originalDataType;
  }
  node.setDataType(retriever.getDefaultSelectedTalendType(originalDataType));
  Object[] children=treeNode.getChildren();
  if (children != null) {
    for (    Object element : children) {
      if (element instanceof ATreeNode) {
        ATreeNode child=(ATreeNode)element;
        String newPath=currentPath + "String_Node_Str";
        if (child.getValue() instanceof String) {
          String elementName=(String)child.getValue();
          if (currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
            continue;
          }
          newPath+=elementName;
        }
 else {
          newPath+="String_Node_Str";
        }
        FOXTreeNode foxChild=cloneATreeNode(child,newPath);
        node.addChild(foxChild);
      }
    }
  }
  return node;
}