#NEWLINE# @ curry #NEWLINE# def leaves_of_type( types , expr ) : #NEWLINE# #INDENT# ' Leaves of an expression skipping all operations of type ``types``\n    ' #NEWLINE# if ( not isinstance ( expr , types ) ) : #NEWLINE# #INDENT# return set ( [ expr ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return set . union ( * map ( leaves_of_type ( expr ) , expr . _inputs ) )