docs: def multidict(ordered_pairs):
      """Convert duplicate keys values to lists."""
      # read all values into lists
      d = defaultdict(list)
      for k, v in ordered_pairs:
          d[k].append(v)
      # unpack lists that have only 1 item
      dict_copy = deepcopy(d)
      for k, v in iteritems(dict_copy):
          if len(v) == 1:
              d[k] = v[0]
      return dict(d)