code: def multidict_to_dict(d):
      
      return dict((k, v[0] if len(v) == 1 else v) for k, v in iterlists(d))
docs: Turns a werkzeug.MultiDict or django.MultiValueDict into a dict with
      list values
      :param d: a MultiDict or MultiValueDict instance
      :return: a dict instance