def METHOD_NAME(self, window):
    # Construct xdotool arguments.
    arguments = []
    for ((button, event_type), flag) in self._flags:
        # Raise an error for unsupported buttons.
        if isinstance(button, str):
            event_type_s = "button" if event_type == 0 else "scroll"
            raise ValueError("Unsupported mouse %s event: %s"
                             % (event_type_s, button))
        # Handle click events.
        if event_type == 0:
            command = "mousedown" if flag else "mouseup"
            arguments.extend([command, str(button)])
        # Handle scroll events.
        else:
            arguments.extend([
                "click", "--repeat", str(flag), "--delay", "0",
                str(button)
            ])
    # Return early if *arguments* is empty.
    if len(arguments) == 0:
        return
    # Send events with xdotool.
    _run_xdotool_command(arguments)