code: def flatten_dict(dict_obj, separator='.', flatten_lists=False):
      reducer = _get_key_reducer(separator)
      flat = {}
      def _flatten_key_val(key, val, parent):
          flat_key = reducer(parent, key)
          try:
              _flatten(val, flat_key)
          except TypeError:
              flat[flat_key] = val
      def _flatten(d, parent=None):
          try:
              for key, val in d.items():
                  _flatten_key_val(key, val, parent)
          except AttributeError:
              if isinstance(d, (str, bytes)):
                  raise TypeError
              for i, value in enumerate(d):
                  _flatten_key_val(str(i), value, parent)
      _flatten(dict_obj)
      return flat