public static String expandPrefix(NavigableSet<String> names,String prefix){
  String name=prefix;
  if (!names.contains(name)) {
    final String closest=names.ceiling(prefix);
    if (closest != null && closest.startsWith(prefix)) {
      final String higher=names.higher(closest);
      if (higher == null || !higher.startsWith(prefix)) {
        name=closest;
      }
    }
  }
  return name;
}

public static String expandPrefix ( NavigableSet < String > names , String prefix ) { String name = prefix ; if ( ! names . contains ( name ) ) { final String closest = names . ceiling ( prefix ) ; if ( closest != null && closest . startsWith ( prefix ) ) { final String higher = names . higher ( closest ) ; if ( higher == null || ! higher . startsWith ( prefix ) ) { name = closest ; } } } return name ; }
expand a name if it is an unambiguous prefix of an entry in the given set of names
