// tok = CNC // returns [(index, tree leaf)] static LPair matchStartUsingWordTree_all(L tok, Map tree) { O best = null; // best leaf int bestIndex = 0; // best index int j = 1; LPair out = new L; while (j < l(tok)) { O def = tree.get(""); if (def != null) { best = def; bestIndex = j; } O t = tree.get(tok.get(j)); j += 2; if (t == null) break; if (!t instanceof Map) break with addPair(out, j, t); // leaf! tree = (Map) t; } if (best != null) addPair(out, bestIndex, best); ret out; }