def is_heap(items_to_check, start_position, compare_fn):
    """
    Determine if the collection is heap.

    Checks if `items_to_check[start_position:]` are in the heap-order
    according to relation defined by `compare_fn`

    Parameters
    ----------
    items_to_check : array_like
        array of items to check
    start_position : integer
        offset of items inside array to check
    compare_fn : callable
        comparator function defining order to check agains

    Returns
    -------
    boolean
        True if items are in heap order
    """
    left_child_index = start_position * 2 + 1
    right_child_index = start_position * 2 + 2

    is_heap_on_left = (
        is_heap(items_to_check, left_child_index, compare_fn)
        and compare_fn(
            items_to_check[start_position],
            items_to_check[left_child_index],
        )
    ) if left_child_index < len(items_to_check) else True

    is_heap_on_right = (
        is_heap(items_to_check, right_child_index, compare_fn)
        and compare_fn(
            items_to_check[start_position],
            items_to_check[right_child_index],
        )
    ) if right_child_index < len(items_to_check) else True

    return is_heap_on_left and is_heap_on_right