nodes: 0, module; 1, function_definition; 2, function_name:group_dict; 3, parameters; 4, block; 5, identifier:items; 6, identifier:keyfunc; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Return a list defaultdict with ``items`` grouped by ``keyfunc``.
  
      >>> sorted(group_dict('eggs', lambda x: x).items())
      [('e', ['e']), ('g', ['g', 'g']), ('s', ['s'])]
      """; 12, assignment; 13, identifier:i; 14, identifier:items; 15, block; 16, identifier:result; 17, identifier:result; 18, call; 19, expression_statement; 20, expression_statement; 21, attribute; 22, argument_list; 23, assignment; 24, call; 25, identifier:collections; 26, identifier:defaultdict; 27, identifier:list; 28, identifier:key; 29, call; 30, attribute; 31, argument_list; 32, identifier:keyfunc; 33, argument_list; 34, subscript; 35, identifier:append; 36, identifier:i; 37, identifier:i; 38, identifier:result; 39, identifier:key
code: def group_dict(items, keyfunc):
      """Return a list defaultdict with ``items`` grouped by ``keyfunc``.
  
      >>> sorted(group_dict('eggs', lambda x: x).items())
      [('e', ['e']), ('g', ['g', 'g']), ('s', ['s'])]
      """
      result = collections.defaultdict(list)
      for i in items:
          key = keyfunc(i)
          result[key].append(i)
      return result