code: def iterate_flattened_separately(dictionary, manually_sorted_keys=None):
      if manually_sorted_keys is None:
          manually_sorted_keys = []
      for key in manually_sorted_keys:
          if key in dictionary:
              yield key, dictionary[key]
      single_line_keys = [key for key in dictionary.keys() if
                          key not in manually_sorted_keys and
                          (not dictionary[key] or
                           not isinstance(dictionary[key], dict))]
      for key in sorted(single_line_keys):
          yield key, dictionary[key]
      multi_line_keys = [key for key in dictionary.keys() if
                         key not in manually_sorted_keys and
                         (dictionary[key] and
                          isinstance(dictionary[key], dict))]
      for key in sorted(multi_line_keys):
          yield key, PATHCHANGE
          for k, val in iterate_flattened_separately(dictionary[key],
                                                     manually_sorted_keys):
              yield join_paths(key, k), val