code: def paint_path(self, gstate, stroke, fill, evenodd, path):
          
          shape = "".join(x[0] for x in path)
          prev_split = 0
          for i in range(len(shape)):
              if shape[i] == "m" and prev_split != i:
                  self.paint_single_path(
                      gstate, stroke, fill, evenodd, path[prev_split:i]
                  )
                  prev_split = i
              if shape[i] == "h":
                  self.paint_single_path(
                      gstate, stroke, fill, evenodd, path[prev_split : i + 1]
                  )
                  prev_split = i + 1
  
          # clean up remaining segments
          if prev_split < len(shape):
              self.paint_single_path(gstate, stroke, fill, evenodd, path[prev_split:])
docs: Converting long paths to small segments each time we m=Move
          or h=ClosePath for polygon