code: def _iter_bitmasks(eid):
      
      bitmask = idaapi.get_first_bmask(eid)
  
      yield bitmask
  
      while bitmask != DEFMASK:
          bitmask = idaapi.get_next_bmask(eid, bitmask)
          yield bitmask
docs: Iterate all bitmasks in a given enum.
  
      Note that while `DEFMASK` indicates no-more-bitmasks, it is also a
      valid bitmask value. The only way to tell if it exists is when iterating
      the serials.