def _binary_search(list, q):
    """
    Returns the index in a list where an item should be found.
     
    Arguments:
    list -- a list of items
    q -- a value to be searched for
    """
    l = 0
    r = len(list)
    while l < r:
        m = (l + r)/2
        if list[m] > q:
            r = m
        else:
            l = m + 1
    return l