tdcommon/src/main/java/thredds/server/catalog/DataRootPathMatcher.java
public String findLongestPathMatch( String reqPath) {
    SortedSet<String> tail = treeSet.tailSet(reqPath);
    if (tail.isEmpty()) return null;
    String after = tail.first();
    if (reqPath.startsWith( after)) // common case
      return tail.first();

    // have to check more, until no common starting chars
    for (String key : tail) {
      if (reqPath.startsWith(key))
        return key;

      // terminate when there's no match at all.
      if (StringUtil2.match(reqPath, key) == 0)
        break;
    }

    return null;
  }
public String findLongestPathMatch( String reqPath) {
    SortedSet<String> tail = treeSet.tailSet(reqPath);
    if (tail.isEmpty()) return null;
    String after = tail.first();
    if (reqPath.startsWith( after)) // common case
      return tail.first();

    // have to check more, until no common starting chars
    for (String key : tail) {
      if (reqPath.startsWith(key))
        return key;

      // terminate when there's no match at all.
      if (StringUtil2.match(reqPath, key) == 0)
        break;
    }

    return null;
  }
Find the longest path match.
@param reqPath find object with longest match where reqPath.startsWith( key)
@return the value whose key is the longest that matches path, or null if none