#NEWLINE# def _before( node ) : #NEWLINE# #INDENT# '\n    Returns the set of all nodes that are before the given node.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# pos = node . treeposition ( ) #NEWLINE# tree = node . root ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# return [ tree [ x ] for x in tree . treepositions ( ) if ( x [ : len ( pos ) ] < pos [ : len ( node ) ] ) ]