#NEWLINE# def drilldown_tree_for_node( node , rel_cls = None , rel_field = None , count_attr = None , cumulative = False ) : #NEWLINE# #INDENT# "\n    Creates a drilldown tree for the given node. A drilldown tree\n    consists of a node's ancestors, itself and its immediate children,\n    all in tree order.\n\n    Optional arguments may be given to specify a ``Model`` class which\n    is related to the node's class, for the purpose of adding related\n    item counts to the node's children:\n\n    ``rel_cls``\n       A ``Model`` class which has a relation to the node's class.\n\n    ``rel_field``\n       The name of the field in ``rel_cls`` which holds the relation\n       to the node's class.\n\n    ``count_attr``\n       The name of an attribute which should be added to each child in\n       the drilldown tree, containing a count of how many instances\n       of ``rel_cls`` are related through ``rel_field``.\n\n    ``cumulative``\n       If ``True``, the count will be for each child and all of its\n       descendants, otherwise it will be for each child itself.\n    " #NEWLINE# if ( rel_cls and rel_field and count_attr ) : #NEWLINE# #INDENT# children = node . _tree_manager . add_related_count ( node . get_children ( ) , rel_cls , rel_field , count_attr , cumulative ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# children = node . get_children ( ) #NEWLINE# #UNINDENT# return itertools . chain ( node . get_ancestors ( ) , [ node ] , children )