def get_pred_and_suc(value, times):
    """
    Return the predecessor and the successor of the value as well as the predecessor of the predecessor of the value
    in the array times.
    :param value: float
    :param times: SortedSet
    :return:
    """
    if len(times) == 2:
        return times[0], times[0], times[1]
    id_before = times.bisect_left(value)
    if value == times[id_before]:
        pred = value
        suc = times[id_before + 1]
        if id_before - 1 < 0:
            pred_pred = times[0]
        else:
            pred_pred = times[id_before - 1]
    else:
        pred = times[id_before - 1]
        suc = times[id_before]
        if id_before - 2 < 0:
            pred_pred = times[0]
        else:
            pred_pred = times[id_before - 2]
    return pred_pred, pred, suc
