def METHOD_NAME(self, code):
    """
    Search the list for the position of the split point for |code|,
    inserting a new split point if necessary. Returns index |i| such
    that |code| == |map[i]|.
    """
    # We use a funky variation on binary search.
    map = self.map
    hi = len(map) - 1
    # Special case: code == map[-1]
    if code == maxint:
        return hi
    # General case
    lo = 0
    # loop invariant: map[lo] <= code < map[hi] and hi - lo >= 2
    while hi - lo >= 4:
        # Find midpoint truncated to even index
        mid = ((lo + hi) // 2) & ~1
        if code < map[mid]:
            hi = mid
        else:
            lo = mid
    # map[lo] <= code < map[hi] and hi - lo == 2
    if map[lo] == code:
        return lo
    else:
        map[hi:hi] = [code, map[hi - 1].copy()]
        return hi