<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _valid_comparison(time_a, time_b, event_a, event_b):
 """True if times can be compared."""

    if time_a == time_b:
        # Ties are only informative if exactly one event happened
        return event_a != event_b
    if event_a and event_b:
        return True
    if event_a and time_a < time_b:
        return True
    if event_b and time_b < time_a:
        return True
    return False