code: private static Segment<PrimitiveParameter> firstSegment(
              PatternFinderUser def, Sequence<PrimitiveParameter> sequence,
              Algorithm algorithm, int maxPatternLength) {
          int size = sequence.size();
          int minPatternLength = minPatternLength(algorithm, def);
          if (size > 0 && size >= minPatternLength) {
              int x = 0;
              int y = minPatternLength < 1 ? size - 1 : minPatternLength - 1;
              if (x <= y) {
                  return resetSegmentHelper(def, sequence, x, y,
                          new Segment<>(sequence, x, y),
                          algorithm, maxPatternLength);
              }
          }
          return null;
      }
docs: Return the first segment of the given sequence to be searched by the
  given <code>PatternFinderUser</code>. If the minimum and maximum
  pattern lengths of the <code>PatternFinderUser</code> are unset, the
  first segment will be the entire sequence.
  
  @param def
  a <code>PatternFinderUser</code> object.
  @param sequence
  a <code>Sequence</code> of <code>PrimitiveParameter</code>
  objects.
  @return a <code>Segment</code> of <code>PrimitiveParameter</code>
  objects.