private static TreeElement cloneTreeElement(TreeElement element) { TreeElement clone; clone = new TreeElement(element.type); clone.apearsInParentParameterInstances = element.apearsInParentParameterInstances; clone.operatorToInstanciate = element.operatorToInstanciate; clone.constantsForOperatorInstance = element.constantsForOperatorInstance; clone.type = element.type; if (element.isBranch()) { clone.childrens = new List <TreeElement>(); foreach (TreeElement iterationChildElement in element.childrens) { clone.childrens.Add(cloneTreeElement(iterationChildElement)); } } return(clone); }