code: def next(self):
          
          seg = Segment(segment_t=idaapi.get_next_seg(self.ea))
  
          if seg.ea <= self.ea:
              raise exceptions.NoMoreSegments("This is the last segment. No segments exist after it.")
  
          return seg
docs: Get the next segment.