def remove_old_values(past_values, earliest_allowed_time):
    """Remove old values from a deque containing (time, value) pairs
    """
    while len(past_values):
        date_added, _ = past_values[0]
        if date_added < earliest_allowed_time:
            v = past_values.popleft()
        else:
            break
