def nearest_larger(arr, i):
    """Finds the nearest item in `arr` which is larger than arr[i]"""
    distance = 1

    while True:
        left = i - distance
        right = i + distance

        if (left < 0) and (right >= len(arr)):
            return None
        if (left >= 0) and (arr[left] > arr[i]):
            return left
        if (right < len(arr)) and (arr[right] > arr[i]):
            return right

        distance += 1

    return None