def active_verifications(candidates, deadline):
    """
    Based on the deadline, only return verification attempts
    that are considered active (non-expired and wasn't created for future)
    """
    relevant_attempts = []
    if not candidates:
        return relevant_attempts

    # Look for a verification that was in effect at the deadline,
    # preferring recent verifications.
    # If no such verification is found, implicitly return empty array
    for verification in candidates:
        if verification.active_at_datetime(deadline):
            relevant_attempts.append(verification)

    return relevant_attempts