code: private void fixdownMaxWithComparator(int k) {
          int c = 2 * k;
          while (c <= size) {
              int m = maxChildOrGrandchildWithComparator(k);
              if (m > c + 1) { // grandchild
                  if (comparator.compare(array[m], array[k]) <= 0) {
                      break;
                  }
                  K tmp = array[k];
                  array[k] = array[m];
                  array[m] = tmp;
                  if (comparator.compare(array[m], array[m / 2]) < 0) {
                      tmp = array[m];
                      array[m] = array[m / 2];
                      array[m / 2] = tmp;
                  }
                  // go down
                  k = m;
                  c = 2 * k;
              } else { // child
                  if (comparator.compare(array[m], array[k]) > 0) {
                      K tmp = array[k];
                      array[k] = array[m];
                      array[m] = tmp;
                  }
                  break;
              }
          }
      }
docs: Downwards fix starting from a particular element at a maximum level.
  Performs comparisons using the comparator.
  
  @param k
  the index of the starting element