code: def parse_flags(headers):
      
      if len(headers) == 0:
          return []
      if sys.version_info[0] == 3:
          headers = bytes(headers, "ascii")
      return list(imaplib.ParseFlags(headers))
docs: Copied from https://github.com/girishramnani/gmail/blob/master/gmail/message.py