def find_event_by_backtracking(
    initial_event, events, condition_fn, break_fn=None
):
    """Backtracks to the first event that matches a specific condition and returns that event"""
    event = initial_event
    visited_events = []
    for _ in range(len(events)):
        if condition_fn(event):
            return event
        if break_fn and break_fn(visited_events):
            event = None
            break
        visited_events.append(event)
        event = next(
            (e for e in events if e["id"] == event["previousEventId"]), None
        )
        if event is None:
            break
    return event