Deep Copy of a LabeledTree
322587
def copy(self):
        
        return LabeledTree(
            udepth = self.udepth,
            depth = self.depth,
            text = self.text,
            label = self.label,
            children = self.children.copy() if self.children != None else [],
            parent = self.parent)
1059787
function deepClone(o, visited) {
			var clone, id, type = _.util.type(o);
			visited = visited || {};

			switch (type) {
				case 'Object':
					id = _.util.objId(o);
					if (visited[id]) {
						return visited[id];
					}
					clone = {};
					visited[id] = clone;

					for (var key in o) {
						if (o.hasOwnProperty(key)) {
							clone[key] = deepClone(o[key], visited);
						}
					}

					return clone;

				case 'Array':
					id = _.util.objId(o);
					if (visited[id]) {
						return visited[id];
					}
					clone = [];
					visited[id] = clone;

					o.forEach(function (v, i) {
						clone[i] = deepClone(v, visited);
					});

					return clone;

				default:
					return o;
			}
		}
1358969
function clone (obj, deep) {
  if (obj) {
    return deep ? deepClone(obj) : objectAssign(isPlainObject(obj) ? {} : [], obj)
  }
  return obj
}
516933
def cloneNode(self, deep: bool=False) -> AbstractNode:
        
        if deep:
            return self._clone_node_deep()
        return self._clone_node()
864294
def node_copy(node, nodefactory=Node):
    """"""
    return nodefactory(node.tag, node.attrib.copy(), node.text,
                       [node_copy(n, nodefactory) for n in node])
117561
def extract_tree(self, labels, without, suppress_unifurcations=True):
        ''''''
        if not isinstance(suppress_unifurcations, bool):
            raise TypeError("suppress_unifurcations must be a bool")
        if labels is not None and not isinstance(labels, set):
            try:
                labels = set(labels)
            except:
                raise TypeError("labels must be iterable")
        label_to_leaf = dict(); keep = set()
        for node in self.traverse_leaves():
            label_to_leaf[str(node)] = node
            if labels is None or (without and str(node) not in labels) or (not without and str(node) in labels):
                keep.add(node)
        for node in list(keep):
            for a in node.traverse_ancestors(include_self=False):
                keep.add(a)
        out = Tree(); out.root.label = self.root.label; out.root.edge_length = self.root.edge_length
        q_old = deque(); q_old.append(self.root)
        q_new = deque(); q_new.append(out.root)
        while len(q_old) != 0:
            n_old = q_old.popleft(); n_new = q_new.popleft()
            for c_old in n_old.children:
                if c_old in keep:
                    c_new = Node(label=str(c_old), edge_length=c_old.edge_length); n_new.add_child(c_new)
                    q_old.append(c_old); q_new.append(c_new)
        if suppress_unifurcations:
            out.suppress_unifurcations()
        return out
901788
def deep_copy(self):
        
        return OrdinalColumn(self.arr, metadata=self.metadata, name=self.name,
                             missing_id=self._missing_id, substitute=True,
                             groupings=self._groupings, weights=self.weights)
949736
def copyNode(self, extended):
        
        ret = libxml2mod.xmlCopyNode(self._o, extended)
        if ret is None:raise treeError('xmlCopyNode() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
855461
def recursive_update(a, b, **kwargs):
    
    copy = kwargs.get('copy', False)
    merge_lists = kwargs.get('merge_lists', True)

    for k, v in b.items():
        if isinstance(v, collections.Mapping):
            if isinstance(a.get(k, None), collections.Mapping):
                recursive_update(a[k], v, **kwargs)
                continue

        elif merge_lists and type(v) is list:
            if type(a.get(k, None)) is list:
                if copy:
                    a[k].extend(deepcopy(v))
                else:
                    a[k].extend(v)
                continue

        # warning, clobbering
        if copy:
            a[k] = deepcopy(v)
        else:
            a[k] = v

    return a
40723
def key_value_to_tree(data):
    '''
    
    '''
    tree = {}
    for flatkey, value in six.iteritems(data):
        t = tree
        keys = flatkey.split(__opts__['pepa_delimiter'])
        for i, key in enumerate(keys, 1):
            if i == len(keys):
                t[key] = value
            else:
                t = t.setdefault(key, {})
    return tree
1358597
def copy(self, name=None):
        
        return Struct.copy(self, deep=True, name=name)
1037029
public static <T> TreeNode<T> copy(TreeDef<T> treeDef, T root) {
		return copy(treeDef, root, Function.identity());
	}
54432
def copytree_hardlink(source, dest):
    
    copy2 = shutil.copy2
    try:
        shutil.copy2 = os.link
        shutil.copytree(source, dest)
    finally:
        shutil.copy2 = copy2
965149
def copyNodeList(self):
        
        ret = libxml2mod.xmlCopyNodeList(self._o)
        if ret is None:raise treeError('xmlCopyNodeList() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
720441
def _get_simple_assignments(tree):
    """"""
    result = {}
    for node in ast.walk(tree):
        if isinstance(node, ast.Assign):
            for target in node.targets:
                if isinstance(target, ast.Name):
                    result[target.id] = node.value
    return result
1287853
function deepCopy(source) {
	let result;
	let type = typeof source;
	if (type !== 'object' || source === null) {
		result = source;
	} else if (source instanceof Array) {
		result = [];
		for (let i = 0, l = source.length; i < l; i++) {
			result[i] = typeof source[i] === 'object' ? deepCopy(source[i]) : source[i];
		}
	} else {
		result = {};
		for (let k in source) {
			result[k] = typeof source[k] === 'object' ? deepCopy(source[k]) : source[k];
		}
	}
	return result;
}
455246
def to_tree(instance, *children):
    

    # Yield representation of self
    yield unicode(instance)

    # Iterate trough each instance child collection
    for i, child in enumerate(children):
        lines = 0

        yield "|"
        yield "+---" + unicode(child)

        if i != len(children) - 1:
            a = "|"
        else:
            a = " "

        # Iterate trough all values of collection of child
        for j, item in enumerate(child.itervalues()):
            if j != len(child) - 1:
                b = "|"
            else:
                b = " "

            if j == 0:
                yield a + "   |"

            # Append prefix to each line
            for k, line in enumerate(item.to_tree()):
                lines += 1

                if k == 0:
                    yield a + "   +---" + line
                else:
                    yield a + "   " + b + "   " + line

        # Add extra space if required
        if len(children) > 1 and i == len(children) - 1 and lines > 1:
            yield a