code: private void heapifyDown(HeapEntry<E> entry) {
      // int size = size();
  
      HeapEntry<E> currentEntry = entry;
      HeapEntry<E> minEntry; // = null;
  
      do {
        minEntry = currentEntry;
  
        HeapEntry<E> leftEntry = leftChild(currentEntry);
        if (leftEntry != null) {
          if (compare(minEntry, leftEntry) > 0) {
            minEntry = leftEntry;
          }
        }
  
        HeapEntry<E> rightEntry = rightChild(currentEntry);
        if (rightEntry != null) {
          if (compare(minEntry, rightEntry) > 0) {
            minEntry = rightEntry;
          }
        }
  
        if (minEntry != currentEntry) {
          // Swap min and current
          swap(minEntry, currentEntry);
          // at start of next loop, we set currentIndex to largestIndex
          // this indexation now holds current, so it is unchanged
        }
      } while (minEntry != currentEntry);
      // System.err.println("Done with heapify down");
      // verify();
    }
docs: On the assumption that
  leftChild(entry) and rightChild(entry) satisfy the heap property,
  make sure that the heap at entry satisfies this property by possibly
  percolating the element o downwards.  I've replaced the obvious
  recursive formulation with an iterative one to gain (marginal) speed