def _what(self, instance, level, depth):
        if level <= 1:
            if depth == 1:
                return Page.objects.toplevel_navigation()
            else:
                return Page.objects.in_navigation().filter(level__lt=depth)

        # mptt starts counting at 0, NavigationNode at 1; if we need the submenu
        # of the current page, we have to add 2 to the mptt level
        if instance.__class__.__name__ != 'PagePretender':
            if instance.level + 2 == level:
                pass
            elif instance.level + 2 < level:
                try:
                    queryset = instance.get_descendants().filter(level=level - 2, in_navigation=True)
                    instance = PageManager.apply_active_filters(queryset)[0]
                except __HOLE__:
                    return []
            else:
                instance = instance.get_ancestors()[level - 2]

        # special case for the navigation extension
        if getattr(instance, 'navigation_extension', None):
            return instance.extended_navigation(depth=depth,
                                                request=self.render_context.get('request', None))
        else:
            if depth == 1:
                try:
                    if instance.__class__.__name__ == 'PagePretender':
                        return instance.children
                    else:
                        return instance.children.in_navigation()
                except:
                    return []
            else:
                queryset = instance.get_descendants().filter(level__lte=instance.level + depth, in_navigation=True)
                return PageManager.apply_active_filters(queryset)
dataset/ETHPy150Open django-leonardo/django-leonardo/leonardo/module/nav/templatetags/webcms_nav_tags.py/NavigationNode._what