code: def flattened_nested_key_indices(nested_dict):
      
      outer_keys, inner_keys = collect_nested_keys(nested_dict)
      combined_keys = list(sorted(set(outer_keys + inner_keys)))
      return {k: i for (i, k) in enumerate(combined_keys)}
docs: Combine the outer and inner keys of nested dictionaries into a single
      ordering.