def hook_get_results(self, changelist):
<EOL>result_list = list(changelist.result_list)<EOL>filter_kwargs = {'<STR_LIT:%s>' % self.left_field: models.F('<STR_LIT:%s>' % self.right_field) - <NUM_LIT:1>}  <EOL>filter_kwargs.update(self.get_immediate_children_filter(self.parent))<EOL>stats_qs = changelist.result_list.filter(**filter_kwargs).values_list('<STR_LIT:id>')<EOL>leafs = [item[<NUM_LIT:0>] for item in stats_qs]<EOL>for result in result_list:<EOL><INDENT>if result.id in leafs:<EOL><INDENT>setattr(result, self.CHILD_COUNT_MODEL_ATTR, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>setattr(result, self.CHILD_COUNT_MODEL_ATTR, '<STR_LIT>')  <EOL><DEDENT><DEDENT>if self.pid:<EOL><INDENT>parent = self.parent<EOL>filter_kwargs = {<EOL>'<STR_LIT>' % self.left_field: getattr(parent, self.left_field),<EOL>'<STR_LIT>' % self.right_field: getattr(parent, self.right_field),<EOL>}<EOL>try:<EOL><INDENT>granparent_id = changelist.model.objects.filter(**filter_kwargs).order_by('<STR_LIT>' % self.left_field)[<NUM_LIT:0>].id<EOL><DEDENT>except IndexError:<EOL><INDENT>granparent_id = None<EOL><DEDENT>if granparent_id != parent.id:<EOL><INDENT>parent = changelist.model(pk=granparent_id)<EOL><DEDENT>setattr(parent, self.UPPER_LEVEL_MODEL_ATTR, True)<EOL>result_list = [parent] + result_list<EOL><DEDENT>changelist.result_list = result_list<EOL>
Triggered by `ChangeList.get_results()`.