nodes: 0, module; 1, function_definition; 2, function_name:flatten_stmts; 3, parameters; 4, block; 5, identifier:stmts; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""Return the full set of unique stms in a pre-assembled stmt graph.
  
      The flattened list of statements returned by this function can be
      compared to the original set of unique statements to make sure no
      statements have been lost during the preassembly process.
  
      Parameters
      ----------
      stmts : list of :py:class:`indra.statements.Statement`
          A list of top-level statements with associated supporting statements
          resulting from building a statement hierarchy with
          :py:meth:`combine_related`.
  
      Returns
      -------
      stmts : list of :py:class:`indra.statements.Statement`
          List of all statements contained in the hierarchical statement graph.
  
      Examples
      --------
      Calling :py:meth:`combine_related` on two statements results in one
      top-level statement; calling :py:func:`flatten_stmts` recovers both:
  
      >>> from indra.preassembler.hierarchy_manager import hierarchies
      >>> braf = Agent('BRAF')
      >>> map2k1 = Agent('MAP2K1')
      >>> st1 = Phosphorylation(braf, map2k1)
      >>> st2 = Phosphorylation(braf, map2k1, residue='S')
      >>> pa = Preassembler(hierarchies, [st1, st2])
      >>> pa.combine_related() # doctest:+ELLIPSIS
      [Phosphorylation(BRAF(), MAP2K1(), S)]
      >>> flattened = flatten_stmts(pa.related_stmts)
      >>> flattened.sort(key=lambda x: x.matches_key())
      >>> flattened
      [Phosphorylation(BRAF(), MAP2K1()), Phosphorylation(BRAF(), MAP2K1(), S)]
      """; 11, assignment; 12, identifier:stmt; 13, identifier:stmts; 14, block; 15, call; 16, identifier:total_stmts; 17, call; 18, if_statement; 19, identifier:list; 20, argument_list; 21, identifier:set; 22, argument_list; 23, attribute; 24, block; 25, identifier:total_stmts; 26, identifier:stmts; 27, identifier:stmt; 28, identifier:supported_by; 29, expression_statement; 30, expression_statement; 31, assignment; 32, assignment; 33, identifier:children; 34, call; 35, identifier:total_stmts; 36, call; 37, identifier:flatten_stmts; 38, argument_list; 39, attribute; 40, argument_list; 41, attribute; 42, identifier:total_stmts; 43, identifier:union; 44, identifier:children; 45, identifier:stmt; 46, identifier:supported_by
code: def flatten_stmts(stmts):
      """Return the full set of unique stms in a pre-assembled stmt graph.
  
      The flattened list of statements returned by this function can be
      compared to the original set of unique statements to make sure no
      statements have been lost during the preassembly process.
  
      Parameters
      ----------
      stmts : list of :py:class:`indra.statements.Statement`
          A list of top-level statements with associated supporting statements
          resulting from building a statement hierarchy with
          :py:meth:`combine_related`.
  
      Returns
      -------
      stmts : list of :py:class:`indra.statements.Statement`
          List of all statements contained in the hierarchical statement graph.
  
      Examples
      --------
      Calling :py:meth:`combine_related` on two statements results in one
      top-level statement; calling :py:func:`flatten_stmts` recovers both:
  
      >>> from indra.preassembler.hierarchy_manager import hierarchies
      >>> braf = Agent('BRAF')
      >>> map2k1 = Agent('MAP2K1')
      >>> st1 = Phosphorylation(braf, map2k1)
      >>> st2 = Phosphorylation(braf, map2k1, residue='S')
      >>> pa = Preassembler(hierarchies, [st1, st2])
      >>> pa.combine_related() # doctest:+ELLIPSIS
      [Phosphorylation(BRAF(), MAP2K1(), S)]
      >>> flattened = flatten_stmts(pa.related_stmts)
      >>> flattened.sort(key=lambda x: x.matches_key())
      >>> flattened
      [Phosphorylation(BRAF(), MAP2K1()), Phosphorylation(BRAF(), MAP2K1(), S)]
      """
      total_stmts = set(stmts)
      for stmt in stmts:
          if stmt.supported_by:
              children = flatten_stmts(stmt.supported_by)
              total_stmts = total_stmts.union(children)
      return list(total_stmts)