code: public static int validateGeohashMaxLevels(Integer userMaxLevels, int defaultMaxLevels) {
          int maxLevels = userMaxLevels == null ? defaultMaxLevels : userMaxLevels;
          if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) {
              throw new IndexException("max_levels must be in range [1, {}], but found {}",
                                       GeohashPrefixTree.getMaxLevelsPossible(),
                                       maxLevels);
          }
          return maxLevels;
      }
docs: Checks if the specified max levels is correct.
  
  @param userMaxLevels the maximum number of levels in the tree
  @param defaultMaxLevels the default max number of levels
  @return the validated max levels