def RestoreListType(response, key_triggers=()):
  """Step (recursively) through a response object and restore list types
  that were overwritten by SOAPpy. Lists with only one element are converted by
  SOAPpy into a dictionary. This handler function restores the proper type.

   Args:
     response: dict Response data object.

  Returns:
    dict Restored data object.
  """
  if not key_triggers: return response

  if isinstance(response, dict):
    if not response.keys(): return response
    dct = {}
    for key in response.keys():
      value = response.get(key)
      if key in key_triggers and not isinstance(value, list):
        value = [value]
      data = RestoreListType(value, key_triggers)
      dct[str(key)] = data
    return dct
  elif isinstance(response, list):
    lst = []
    for item in response:
      lst.append(RestoreListType(item, key_triggers))
    return lst
  else:
    return response