def _check_handler_present(logger, handler_type, *compare):
    """
    Check if a handler of given and with given attributes
    has been added to the logger already.
    :param logging.Logger logger: logger whose handlers to check
    :param type handler_type: handler class to check for
    :param [(str, obj)] compare:
        list of (attribute, value) items to check the handler against
        (e.g., (stream, sys.stderr) will check if handler.stream == sys.stderr)
    :returns: True if such a handler is configured, False otherwise
    :rtype: bool
    """
    for handler in logger.handlers:
        if isinstance(handler, handler_type):
            attrs_match = True
            for attr, value in compare:
                try:
                    if getattr(handler, attr) != value:
                        attrs_match = False
                        break
                except AttributeError:
                    continue
            if attrs_match:
                return True
    return False