implementation for max_heapify method