<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def has_event_handler(self, handler, event_name=None):
 """Check if the specified event has the specified handler. Args: handler (callable):
 the callable event handler. event_name: The event the handler attached to. Set this to ``None`` to search all events. """

        if event_name is not None:
            if event_name not in self._event_handlers:
                return False
            events = [event_name]
        else:
            events = self._event_handlers
        for e in events:
            for h, _, _ in self._event_handlers[e]:
                if h == handler:
                    return True
        return False