<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run(self):
 """Create a category tree."""

        config = self.state.document.settings.env.config

        # Group processes by category
        processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
        processes.sort(key=itemgetter('category'))
        categorized_processes = {k: list(g) for k, g in groupby(processes, itemgetter('category'))}

        # Build category tree
        category_sections = {'': nodes.container(ids=['categories'])}
        top_categories = []

        for category in sorted(categorized_processes.keys()):
            category_path = ''

            for category_node in category.split(':'):
                parent_category_path = category_path
                category_path += '{}:'.format(category_node)

                if category_path in category_sections:
                    continue

                category_name = category_node.capitalize()

                section = nodes.section(ids=['category-' + category_node])
                section += nodes.title(category_name, category_name)

                # Add process list
                category_key = category_path[:-1]
                if category_key in categorized_processes:
                    listnode = nodes.bullet_list()
                    section += listnode

                    for process in categorized_processes[category_key]:
                        par = nodes.paragraph()

                        node = nodes.reference('', process['name'], internal=True)
                        node['refuri'] = config.autoprocess_definitions_uri + '#process-' + process['slug']
                        node['reftitle'] = process['name']

                        par += node
                        listnode += nodes.list_item('', par)

                category_sections[parent_category_path] += section
                category_sections[category_path] = section

                if parent_category_path == '':
                    top_categories.append(section)

        # Return top sections only
        return top_categories