private String findHighestToVersion(String toVersion){
  if (versionChanges.get(toVersion) == null) {
    List<String> toVersions=new ArrayList<String>(versionChanges.keySet());
    Collections.sort(toVersions,Collections.reverseOrder());
    for (    String version : toVersions) {
      if (version.compareTo(toVersion) <= 0) {
        return version;
      }
    }
    throw new IllegalArgumentException("No version found in rules that matches the given to-version:" + toVersion);
  }
 else {
    return toVersion;
  }
}

private String findHighestToVersion ( String toVersion ) { if ( versionChanges . get ( toVersion ) == null ) { List < String > toVersions = new ArrayList < String > ( versionChanges . keySet ( ) ) ; Collections . sort ( toVersions , Collections . reverseOrder ( ) ) ; for ( String version : toVersions ) { if ( version . compareTo ( toVersion ) <= 0 ) { return version ; } } throw new IllegalArgumentException ( "No version found in rules that matches the given to-version:" + toVersion ) ; } else { return toVersion ; } }
find highest version below the given to - version for which there are rules registered .
