int highDescendant(int i, boolean min) {
    int size = heap.size();
    
    // look among children
    int j = firstChild(i);
    if (j >= size) {
      return -1;
    }
    E high = heap.get(j);
    int p = j;
    E e;
    j++;
    if (j < size) {
      int cmp = compare(e = heap.get(j), high);
      if (min ? cmp < 0 : cmp > 0) {
        high = e;
        p = j;
      }
      
      // look among grandchildren
      int g = firstGrandChild(i);
      for (j = g; j < size && j < g + 4; j++) {
        cmp = compare(e = heap.get(j), high);
        if (min ? cmp < 0 : cmp > 0) {
          high = e;
          p = j;
        }
      }
    }
    return p;
  }