code: protected List<HString> longestMatchFirst(@NonNull HString source) {
        List<HString> results = new LinkedList<>();
        List<Annotation> tokens = source.tokens();
        Predicate<HString> prefix = (this instanceof PrefixSearchable)
                                    ? Cast.<PrefixSearchable>as(this)::isPrefixMatch
                                    : h -> true;
  
        for (int i = 0; i < tokens.size(); ) {
           Annotation token = tokens.get(i);
           if (prefix.test(token)) {
  
              LexiconMatch bestMatch = null;
              for (int j = i + 1; j <= tokens.size() && j < (i + 1 + longestLemma); j++) {
                 HString temp = HString.union(tokens.subList(i, j));
                 List<LexiconEntry> entries = getEntries(temp);
                 if (entries.size() > 0) {
                    bestMatch = new LexiconMatch(temp, entries.get(0));
                 }
                 if (!prefix.test(temp)) {
                    break;
                 }
              }
  
              if (bestMatch != null) {
                 results.add(createFragment(bestMatch));
                 i += bestMatch.getSpan().tokenLength();
              } else {
                 i++;
              }
  
           } else if (test(token)) {
              results.add(createFragment(new LexiconMatch(token, getEntries(token).get(0))));
              i++;
           } else {
              i++;
           }
        }
  
        return results;
     }
docs: Longest match first list.
  
  @param source the source
  @return the list