@staticmethod
  def FixDown(heap, i, j):
    while True:
      if j < i * 2: break

      m = 2 * i if (j == i * 2 or heap[2*i] < heap[2*i+1]) else 2*i+1
      if heap[m] < heap[i]:
        Heap.Swap(heap, i, m)
        i = m  # FixDown(heap, m, j)
      else:
        break
Traverse down the heap, ensuring the invariant is maintained.
dataset/ETHPy150Open steveniemitz/scales/scales/loadbalancer/heap.py/Heap.FixDown