nodes: 0, module; 1, function_definition; 2, function_name:recursive_refs; 3, parameters; 4, block; 5, identifier:envs; 6, identifier:name; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, comment:"""
      Return set of recursive refs for given env name
  
      >>> local_refs = sorted(recursive_refs([
      ...     {'name': 'base', 'refs': []},
      ...     {'name': 'test', 'refs': ['base']},
      ...     {'name': 'local', 'refs': ['test']},
      ... ], 'local'))
      >>> local_refs == ['base', 'test']
      True
      """; 13, assignment; 14, assignment; 15, identifier:refs; 16, block; 17, else_clause; 18, call; 19, identifier:refs_by_name; 20, dictionary_comprehension; 21, identifier:refs; 22, subscript; 23, expression_statement; 24, block; 25, attribute; 26, argument_list; 27, pair; 28, for_in_clause; 29, identifier:refs_by_name; 30, identifier:name; 31, assignment; 32, expression_statement; 33, identifier:set; 34, identifier:union; 35, identifier:refs; 36, identifier:indirect_refs; 37, subscript; 38, call; 39, identifier:env; 40, identifier:envs; 41, identifier:indirect_refs; 42, call; 43, assignment; 44, identifier:env; 45, string; 46, identifier:set; 47, argument_list; 48, identifier:set; 49, argument_list; 50, identifier:indirect_refs; 51, call; 52, string_content:name; 53, subscript; 54, call; 55, identifier:set; 56, argument_list; 57, identifier:env; 58, string; 59, attribute; 60, argument_list; 61, string_content:refs; 62, attribute; 63, identifier:from_iterable; 64, list_comprehension; 65, identifier:itertools; 66, identifier:chain; 67, call; 68, for_in_clause; 69, identifier:recursive_refs; 70, argument_list; 71, identifier:ref; 72, identifier:refs; 73, identifier:envs; 74, identifier:ref
code: def recursive_refs(envs, name):
      """
      Return set of recursive refs for given env name
  
      >>> local_refs = sorted(recursive_refs([
      ...     {'name': 'base', 'refs': []},
      ...     {'name': 'test', 'refs': ['base']},
      ...     {'name': 'local', 'refs': ['test']},
      ... ], 'local'))
      >>> local_refs == ['base', 'test']
      True
      """
      refs_by_name = {
          env['name']: set(env['refs'])
          for env in envs
      }
      refs = refs_by_name[name]
      if refs:
          indirect_refs = set(itertools.chain.from_iterable([
              recursive_refs(envs, ref)
              for ref in refs
          ]))
      else:
          indirect_refs = set()
      return set.union(refs, indirect_refs)