code: private static <E> Entry<PrefixKey, E> getParentEntry(
        TreeMap<PrefixKey, E> map, PrefixKey upperBound) {
      NavigableMap<PrefixKey, E> head = map.headMap(upperBound, true).descendingMap();
      for (Entry<PrefixKey, E> entry : head.entrySet()) {
        if (upperBound.isParent(entry.getKey())) {
          return entry;
        }
      }
      return null;
    }
docs: Helper function that finds the parent entry (inclusive) for the given upper bound. This is like
  {@link TreeMap#floorEntry(Object)}, but does additional filtering.
  
  @param map the map to find the parent entry in.
  @param upperBound the upper bound to search for a parent.
  @return the parent entry for the given upper bound, null if no entry was found.