def _recursive_helper(tree, start_index, end_index, array):
    """Recursively insert middle element in sub-array into a binary search tree

    Parameters
    ----------
    tree : BinarySearchTree
        Tree to insert elements into
    start_index : int
        Index in array denoting start of sub-array
    end_index : int
        Index in array denoting end of sub-array
    array : list of any
        Array that we are inserting elements into tree from. Can contain any
        Python object that allows comparison.

    Returns
    -------
    tree : BinarySearchTree
        Input tree if with relevant elements from array inserted
    """
    # Break case, when start index and end index overlap
    if end_index < start_index:
        return tree

    # Find and insert mid element
    mid_index = int((start_index + end_index) / 2)
    tree.insert(array[mid_index])

    # Recusively insert mid element of sub-array on left half of this
    # sub-array
    tree = _recursive_helper(tree, start_index, mid_index - 1, array)

    # Recusively insert mid element of sub-array on right half of this
    # sub-array
    tree = _recursive_helper(tree, mid_index + 1, end_index, array)

    return tree