nodes: 0, module; 1, function_definition; 2, function_name:flatten_; 3, parameters; 4, block; 5, identifier:structure; 6, expression_statement; 7, if_statement; 8, if_statement; 9, return_statement; 10, comment:"""Combine all leaves of a nested structure into a tuple.
  
    The nested structure can consist of any combination of tuples, lists, and
    dicts. Dictionary keys will be discarded but values will ordered by the
    sorting of the keys.
  
    Args:
      structure: Nested structure.
  
    Returns:
      Flat tuple.
    """; 11, call; 12, block; 13, call; 14, block; 15, tuple; 16, identifier:isinstance; 17, argument_list; 18, if_statement; 19, identifier:isinstance; 20, argument_list; 21, expression_statement; 22, for_statement; 23, return_statement; 24, identifier:structure; 25, identifier:structure; 26, identifier:dict; 27, identifier:structure; 28, block; 29, else_clause; 30, identifier:structure; 31, tuple; 32, assignment; 33, identifier:element; 34, identifier:structure; 35, block; 36, call; 37, expression_statement; 38, comment:# Zip doesn't work on an the items of an empty dictionary.; 39, block; 40, identifier:tuple; 41, identifier:list; 42, identifier:result; 43, list; 44, expression_statement; 45, identifier:tuple; 46, argument_list; 47, assignment; 48, expression_statement; 49, augmented_assignment; 50, identifier:result; 51, identifier:structure; 52, subscript; 53, assignment; 54, identifier:result; 55, call; 56, call; 57, integer:1; 58, identifier:structure; 59, tuple; 60, identifier:flatten_; 61, argument_list; 62, identifier:zip; 63, argument_list; 64, identifier:element; 65, list_splat; 66, call; 67, identifier:sorted; 68, argument_list; 69, call; 70, keyword_argument; 71, attribute; 72, argument_list; 73, identifier:key; 74, lambda; 75, identifier:structure; 76, identifier:items; 77, lambda_parameters; 78, subscript; 79, identifier:x; 80, identifier:x; 81, integer:0
code: def flatten_(structure):
    """Combine all leaves of a nested structure into a tuple.
  
    The nested structure can consist of any combination of tuples, lists, and
    dicts. Dictionary keys will be discarded but values will ordered by the
    sorting of the keys.
  
    Args:
      structure: Nested structure.
  
    Returns:
      Flat tuple.
    """
    if isinstance(structure, dict):
      if structure:
        structure = zip(*sorted(structure.items(), key=lambda x: x[0]))[1]
      else:
        # Zip doesn't work on an the items of an empty dictionary.
        structure = ()
    if isinstance(structure, (tuple, list)):
      result = []
      for element in structure:
        result += flatten_(element)
      return tuple(result)
    return (structure,)