#NEWLINE# def _split_tree( layout ) : #NEWLINE# #INDENT# 'Return a tuple of two layouts, one containing the left\n    subtree of the root vertex, and one containing the original tree\n    with the left subtree removed.' #NEWLINE# one_found = False #NEWLINE# m = None #NEWLINE# for i in range ( len ( layout ) ) : #NEWLINE# #INDENT# if ( layout [ i ] == 1 ) : #NEWLINE# #INDENT# if one_found : #NEWLINE# #INDENT# m = i #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# one_found = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( m is None ) : #NEWLINE# #INDENT# m = len ( layout ) #NEWLINE# #UNINDENT# left = [ ( layout [ i ] - 1 ) for i in range ( 1 , m ) ] #NEWLINE# rest = ( [ 0 ] + [ layout [ i ] for i in range ( m , len ( layout ) ) ] ) #NEWLINE# return ( left , rest )