private void heapify(int indexOfParent) {
        /**
         * First declare all relevant variables for clarity
         */
        int indexOfLeftChild = left(indexOfParent);
        int indexOfRightChild = right(indexOfParent);
        int indexOfSmallerChild;
        E parent = heap.get(indexOfParent);
        E leftChild = heap.get(indexOfLeftChild);
        E rightChild = heap.get(indexOfRightChild);
        E smallerChild;
        /**
         * Due to the way DynamicArray is implemented, it is known that if
         * an index i is out of bounds, get(i) returns null.
         */
        if (leftChild != null) {
            if (rightChild != null) {
                if (leftChild.compareTo(rightChild) < 0) {
                    indexOfSmallerChild = indexOfLeftChild;
                } else {
                    indexOfSmallerChild = indexOfRightChild;
                }
            } else {
                indexOfSmallerChild = indexOfLeftChild;
            }
            smallerChild = heap.get(indexOfSmallerChild);
            if (parent.compareTo(smallerChild) > 0) {
                swapElementsByIndex(indexOfParent, indexOfSmallerChild);
                heapify(indexOfSmallerChild);
            }
        }
    }