code: def merge_nested_environment_dicts(env_dicts, env_name=None, env_root=None):
      
      # If the provided dictionary is just a single "level" (no nested
      # environments), it applies to all environments
      if all(isinstance(val, (six.string_types, list))
             for (_key, val) in env_dicts.items()):
          return flatten_path_lists(env_dicts, env_root)
  
      if env_name is None:
          if env_dicts.get('*'):
              return flatten_path_lists(env_dicts.get('*'), env_root)
          raise AttributeError("Provided config key:val pairs %s aren't usable with no environment provided" % env_dicts)  # noqa pylint: disable=line-too-long
  
      if not env_dicts.get('*') and not env_dicts.get(env_name):
          raise AttributeError("Provided config key:val pairs %s aren't usable with environment %s" % (env_dicts, env_name))  # noqa pylint: disable=line-too-long
  
      combined_dicts = merge_dicts(env_dicts.get('*', {}),
                                   env_dicts.get(env_name, {}))
      return flatten_path_lists(combined_dicts, env_root)
docs: Return single-level dictionary from dictionary of dictionaries.