def auto_toc_tree(self, node):  
if not self.config['<STR_LIT>']:<EOL><INDENT>return None<EOL><DEDENT>sec = self.config['<STR_LIT>']<EOL>if sec is not None:<EOL><INDENT>if node.parent is None:<EOL><INDENT>return None<EOL><DEDENT>title = None<EOL>if isinstance(node.parent, nodes.section):<EOL><INDENT>child = node.parent.first_child_matching_class(nodes.title)<EOL>if child is not None:<EOL><INDENT>title = node.parent.children[child]<EOL><DEDENT><DEDENT>elif isinstance(node.parent, nodes.paragraph):<EOL><INDENT>child = node.parent.parent.first_child_matching_class(nodes.title)<EOL>if child is not None:<EOL><INDENT>title = node.parent.parent.children[child]<EOL><DEDENT><DEDENT>if not title:<EOL><INDENT>return None<EOL><DEDENT>if title.astext().strip() != sec:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>numbered = None<EOL>if isinstance(node, nodes.bullet_list):<EOL><INDENT>numbered = <NUM_LIT:0><EOL><DEDENT>elif isinstance(node, nodes.enumerated_list):<EOL><INDENT>numbered = <NUM_LIT:1><EOL><DEDENT>if numbered is None:<EOL><INDENT>return None<EOL><DEDENT>refs = []<EOL>for nd in node.children[:]:<EOL><INDENT>assert isinstance(nd, nodes.list_item)<EOL>if len(nd.children) != <NUM_LIT:1>:<EOL><INDENT>return None<EOL><DEDENT>par = nd.children[<NUM_LIT:0>]<EOL>if not isinstance(par, nodes.paragraph):<EOL><INDENT>return None<EOL><DEDENT>if len(par.children) != <NUM_LIT:1>:<EOL><INDENT>return None<EOL><DEDENT>ref = par.children[<NUM_LIT:0>]<EOL>if isinstance(ref, addnodes.pending_xref):<EOL><INDENT>ref = ref.children[<NUM_LIT:0>]<EOL><DEDENT>if not isinstance(ref, nodes.reference):<EOL><INDENT>return None<EOL><DEDENT>title, uri, docpath = self.parse_ref(ref)<EOL>if title is None or uri.startswith('<STR_LIT:#>'):<EOL><INDENT>return None<EOL><DEDENT>if docpath:<EOL><INDENT>refs.append((title, docpath))<EOL><DEDENT>else:<EOL><INDENT>refs.append((title, uri))<EOL><DEDENT><DEDENT>self.state_machine.reset(self.document,<EOL>node.parent,<EOL>self.current_level)<EOL>return self.state_machine.run_directive(<EOL>'<STR_LIT>',<EOL>options={'<STR_LIT>': <NUM_LIT:1>, '<STR_LIT>': numbered},<EOL>content=['<STR_LIT>' % (k, v) for k, v in refs])<EOL>
Try to convert a list block to toctree in rst.

        This function detects if the matches the condition and return
        a converted toc tree node. The matching condition:
        The list only contains one level, and only contains references

        Parameters
        ----------
        node: nodes.Sequential
            A list node in the doctree

        Returns
        -------
        tocnode: docutils node
            The converted toc tree node, None if conversion is not possible.