<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_listener_instance(self, cls):
 """If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener` """

        with self._lock:
            for listener in self._listeners:
                if isinstance(listener, cls):
                    return listener