static <A, B> TreeMap<A, B> asRevTreeMap(Map<A, B> map) {
  Comparator<A> comparator = reverseComparator();
  if (isTreeMapWithComparator(map, comparator))
    ret (TreeMap) map;
  var m2 = new TreeMap(comparator);
  m2.putAll(map);
  ret m2;
}