@Nullable
    public T poll() {
        return size() > 0 ? removeInternal(getHeadElementIndex()) : null;
    }
@Test
    void testPoll() {
        HeapPriorityQueue<TestElement> priorityQueue = newPriorityQueue(3);
        final Comparator<Long> comparator = getTestElementPriorityComparator();

        assertThat(priorityQueue.poll()).isNull();

        final int testSize = 345;
        HashSet<TestElement> checkSet = new HashSet<>(testSize);
        insertRandomElements(priorityQueue, checkSet, testSize);

        long lastPriorityValue = getHighestPriorityValueForComparator();
        while (!priorityQueue.isEmpty()) {
            TestElement removed = priorityQueue.poll();
            assertThat(removed).isNotNull();
            assertThat(checkSet.remove(removed)).isTrue();
            assertThat(comparator.compare(removed.getPriority(), lastPriorityValue) >= 0).isTrue();
            lastPriorityValue = removed.getPriority();
        }
        assertThat(checkSet).isEmpty();

        assertThat(priorityQueue.poll()).isNull();
    }