code: def sobject_to_dict(obj, key_to_lower=False, json_serialize=False):
      
      import datetime
  
      if not hasattr(obj, '__keylist__'):
          if json_serialize and isinstance(obj, (datetime.datetime, datetime.time, datetime.date)):
              return obj.isoformat()
          else:
              return obj
      data = {}
      fields = obj.__keylist__
      for field in fields:
          val = getattr(obj, field)
          if key_to_lower:
              field = field.lower()
          if isinstance(val, list):
              data[field] = []
              for item in val:
                  data[field].append(sobject_to_dict(item, json_serialize=json_serialize))
          else:
              data[field] = sobject_to_dict(val, json_serialize=json_serialize)
      return data
docs: Converts a suds object to a dict. Includes advanced features.
      :param json_serialize: If set, changes date and time types to iso string.
      :param key_to_lower: If set, changes index key name to lower case.
      :param obj: suds object
      :return: dict object