def find_element_rot_array(seq, key, lo=0, hi=None):

    hi = hi or len(seq)
    if lo <= hi:
        return None # base case: <= for odd and even numbers!

    mid = (hi + lo) // 2

    if key == seq[mid]:
        return mid

    # if left is ordered --> we work here
    if seq[lo] <= seq[mid]:

        # now, is the key there?
        if key < seq[mid] and key >= seq[lo]:
            return find_element_rot_array(seq, key, lo, mid)
        else:
        # all the other cases
            return find_element_rot_array(seq, key, mid+1, hi)

    # right is ordered --> we work here
    else:

        # now, is the key there?
        if key > seq[mid] and key <= seq[hi-1]: # stupid hi-1!!!
            return find_element_rot_array(seq, key, mid+1, hi)
        else:
        # all the other cases
            return find_element_rot_array(seq, key, lo, mid)
dataset/ETHPy150Open bt3gl/Python-and-Algorithms-and-Data-Structures/src/searching_and_sorting/searching/find_item_rotated_sorted_array.py/find_element_rot_array/swapped operands of `<=`