docs: def allocate_mid(mids):
      """
      Allocate a MID which has not been used yet.
      """
      i = 0
      while True:
          mid = str(i)
          if mid not in mids:
              mids.add(mid)
              return mid
          i += 1