Binary search for the interval containing index,
        assuming there is such an interval.
        This function should never return ``None``.

def _binary_search_intervals(cls, intervals, index):
        """
        Binary search for the interval containing index,
        assuming there is such an interval.
        This function should never return ``None``.
        """
        start = 0
        end = len(intervals) - 1
        while start <= end:
            middle_index = start + ((end - start) // 2)
            middle = intervals[middle_index]
            if (middle[0] <= index) and (index < middle[1]):
                return middle
            elif middle[0] > index:
                end = middle_index - 1
            else:
                start = middle_index + 1
        return None