code: private static Segment<PrimitiveParameter> nextSegmentAfterMatch(
              PatternFinderUser def, Segment<PrimitiveParameter> seg,
              Algorithm algorithm, int minPatternLength, int maxPatternLength) {
          if (seg == null) {
              return null;
          }
  
          int arg;
          int x = seg.getFirstIndex();
          int y = seg.getLastIndex();
  
          Segment<PrimitiveParameter> nextSeg = null;
          if ((arg = def.getMaxOverlapping()) > 0) {
              int myCurrentColumn = y - (arg + 1);
              if (myCurrentColumn - 1 > x) {
                  nextSeg = resetSegment(def, seg, myCurrentColumn, getYIndex(
                          def, myCurrentColumn, seg), algorithm,
                          minPatternLength, maxPatternLength);
              } else {
                  nextSeg = resetSegment(def, seg, getXIndex(def, x, seg),
                          getYIndex(def, y + 1, seg), algorithm,
                          minPatternLength, maxPatternLength);
              }
          } else {
              nextSeg = resetSegment(def, seg, getXIndex(def, x, seg), getYIndex(
                      def, y + 1, seg), algorithm, minPatternLength,
                      maxPatternLength);
          }
  
          return nextSeg;
      }
docs: Return the next segment to be searched if the most recently searched
  segment matched this rule. The returned segment is calculated according
  to the this rule's search parameters.
  
  @param ts
  the sequence being searched.
  @param seg
  the most recently searched segment.
  @param lastMatch
  the most recent segment to match this rule.
  @return the next segment that should be searched, or null if there are no
  more segments to search.