def get_category_tree(self):
        from lfs.catalog.models import Category
        # NOTE: We don't use the level attribute of the category but calculate
        # actual position of a category based on the current tree. In this way
        # the category tree always start with level 1 (even if we start with
        # category level 2) an the correct css is applied.
        level = 0
        categories = []
        for category in Category.objects.filter(level=self.start_level):

            if category.exclude_from_navigation:
                continue

            if self.currents and category in self.currents:
                children = self._get_sub_tree(category, level + 1)
                is_current = True
            elif category.level <= self.expand_level:
                children = self._get_sub_tree(category, level + 1)
                is_current = False
            else:
                children = []
                is_current = False

            if self.start_level > 1:
                if category.parent in self.currents:
                    categories.append({
                        "category": category,
                        "children": children,
                        "level": level,
                        "is_current": is_current,
                    })
            else:
                categories.append({
                    "category": category,
                    "children": children,
                    "level": level,
                    "is_current": is_current,
                })

        return categories
Test index page api/status
dataset/ETHPy150Open diefenbach/django-lfs/lfs/core/utils.py/CategoryTree.get_category_tree--crossover with--dataset/ETHPy150Open treeio/treeio/treeio/projects/api/tests.py/ProjectsAPITest.test_get_status_list