def _binary_search(esum, A, a, b):
    """
    >>> A = [(2, 2, 2, 2), (2, 3, 3), (3, 3, 2), (4, 4)]
    >>> _binary_search((4, 4), A, 0, len(A)-1)
    True
    >>> _binary_search((4, 4), A, 0, len(A)-2)
    False
    >>> _binary_search((5, 5), A, 0, len(A)-1)
    False
    """
    while a <= b:
        mid = (a + b) // 2
        if A[mid] == esum:
            return True
        if esum < A[mid]:
            b = mid - 1
        else:
            a = mid + 1
    return False
