def get_lr(T, s):
    """
    Returns the left and right neighbors (branches) of s in T.
    """
    try:
        sl = T.floor_key(s)
    except KeyError:
        sl = None
    try:
        sr = T.ceiling_key(s)
    except KeyError:
        sr = None
    return sl, sr