#NEWLINE# def recurse_tree( self , attr ) : #NEWLINE# #INDENT# "Recurse M2M relationship tree, extending list as we go.\n\n        :param attr: str, name of attribute we wish to traverse.\n            .e.g. 'children', or 'parents'\n\n        " #NEWLINE# nodes = [ ] #NEWLINE# node_type = getattr ( self , attr ) #NEWLINE# for node in node_type . all ( ) : #NEWLINE# #INDENT# nodes . extend ( node . recurse_tree ( attr ) ) #NEWLINE# #UNINDENT# nodes . extend ( node_type . all ( ) ) #NEWLINE# return node_type