#NEWLINE# def treepositions_no_leaves( tree ) : #NEWLINE# #INDENT# '\n    Returns all the tree positions in the given tree which are not\n    leaf nodes.\n    ' #NEWLINE# treepositions = tree . treepositions ( ) #NEWLINE# prefixes = set ( ) #NEWLINE# for pos in treepositions : #NEWLINE# #INDENT# for length in range ( len ( pos ) ) : #NEWLINE# #INDENT# prefixes . add ( pos [ : length ] ) #NEWLINE# #UNINDENT# #UNINDENT# return [ pos for pos in length if ( pos in prefixes ) ]