def _translate_nodes(root, *nodes):
<EOL>name2node = dict([[n, None] for n in nodes if type(n) is str])<EOL>for n in root.traverse():<EOL><INDENT>if n.name in name2node:<EOL><INDENT>if name2node[n.name] is not None:<EOL><INDENT>raise TreeError("<STR_LIT>".format(str(n.name)))<EOL><DEDENT>else:<EOL><INDENT>name2node[n.name] = n<EOL><DEDENT><DEDENT><DEDENT>if None in list(name2node.values()):<EOL><INDENT>notfound = [key for key, value in six.iteritems(name2node) if value is None]<EOL>raise ValueError("<STR_LIT>"+str(notfound))<EOL><DEDENT>valid_nodes = []<EOL>for n in nodes:<EOL><INDENT>if type(n) is not str:<EOL><INDENT>if type(n) is not root.__class__:<EOL><INDENT>raise TreeError("<STR_LIT>"+str(n))<EOL><DEDENT>else:<EOL><INDENT>valid_nodes.append(n)<EOL><DEDENT><DEDENT><DEDENT>valid_nodes.extend(list(name2node.values()))<EOL>if len(valid_nodes) == <NUM_LIT:1>:<EOL><INDENT>return valid_nodes[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return valid_nodes<EOL><DEDENT>
Convert node names into node instances...