def safebisect(intervals, x):
    'Safe list bisection that handles None gracefully'
    if (x is None):
        return None
    return bisect(intervals, x)
Safe list bisection that handles None gracefully
def safebisect(intervals, x):
    
    if (x is None):
        return None
    return bisect(intervals, x)