sS longestPrefixInCISet_charSequence(CharSequence s, TreeSet set) { if (set == null || s == null) null; while licensed { S key = set.floor(s); ifdef startsWithOneOf_treeSet_debug print(s + " => " + key); endifdef if (key == null) null; // s is in front of whole set => no prefix in there int n = lCommonPrefixIC(key, s); if (n == l(key)) ret key; // found! s = takeFirst(s, n); // shorten and try again } null; // dummy }