def read_newick(newick, root_node=None, format=<NUM_LIT:0>):
<EOL>if isinstance(newick, six.string_types):   <EOL><INDENT>if os.path.exists(newick):<EOL><INDENT>if newick.endswith('<STR_LIT>'):<EOL><INDENT>import gzip<EOL>nw = gzip.open(newick).read()<EOL><DEDENT>else:<EOL><INDENT>nw = open(newick, '<STR_LIT>').read()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>nw = newick<EOL><DEDENT>matcher = compile_matchers(formatcode=format)<EOL>nw = nw.strip()        <EOL>if not nw.startswith('<STR_LIT:(>') and nw.endswith('<STR_LIT:;>'):<EOL><INDENT>return _read_node_data(nw[:-<NUM_LIT:1>], root_node, "<STR_LIT>", matcher, format)<EOL><DEDENT>elif not nw.startswith('<STR_LIT:(>') or not nw.endswith('<STR_LIT:;>'):<EOL><INDENT>raise NewickError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return _read_newick_from_string(nw, root_node, matcher, format)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NewickError("<STR_LIT>")<EOL><DEDENT>
Reads a newick tree from either a string or a file, and returns
an ETE tree structure.

A previously existent node object can be passed as the root of the
tree, which means that all its new children will belong to the same
class as the root (This allows to work with custom TreeNode objects).

You can also take advantage from this behaviour to concatenate
several tree structures.