public T max() {
        /* Check whether we're empty. */
        if (isEmpty())
            throw new NoSuchElementException("Empty heap.");

        /* There are two cases:
         * 1. If there is exactly one element in the heap, then it would be in the
         *    "low" slot of the heap node.
         * 2. Otherwise, the max element is in the "high" slot of the topmost
         *    node.
         */
        return size() == 1? elems.get(1).low : elems.get(1).high; // Array is one-indexed.
    }