def _build_tree_structure(queryset):
 all_nodes = {}
 mptt_opts = queryset.model._mptt_meta
 items = queryset.order_by(mptt_opts.tree_id_attr, mptt_opts.left_attr).values_list(u'pk', (u'%s_id' % mptt_opts.parent_attr))
 for (p_id, parent_id) in items:
  all_nodes.setdefault((str(parent_id) if parent_id else 0), []).append(p_id)
 return all_nodes

def _build_tree_structure ( queryset ) : all_nodes = { } mptt_opts = queryset . model . _mptt_meta items = queryset . order_by ( mptt_opts . tree_id_attr , mptt_opts . left_attr ) . values_list ( u'pk' , ( u'%s_id' % mptt_opts . parent_attr ) ) for ( p_id , parent_id ) in items : all_nodes . setdefault ( ( str ( parent_id ) if parent_id else 0 ) , [ ] ) . append ( p_id ) return all_nodes
build an in-memory representation of the item tree .