code: public int[] partition(double h) {
          for (int i = 0; i < height.length - 1; i++) {
              if (height[i] > height[i + 1]) {
                  throw new IllegalStateException("Non-monotonic cluster tree -- the linkage is probably not appropriate!");
              }
          }
  
          int n = merge.length + 1;
          int k = 2;
          for (; k <= n; k++) {
              if (height[n - k] < h) {
                  break;
              }
          }
  
          if (k <= 2) {
              throw new IllegalArgumentException("The parameter h is too large.");
          }
  
          return partition(k - 1);
      }
docs: Cuts a tree into several groups by specifying the cut height.
  @param h the cut height.
  @return the cluster label of each sample.