def METHOD_NAME(self, matcher, error):
    try:
        starting_handle = self.driver.current_window_handle
    except NoSuchWindowException:
        starting_handle = None
    for handle in self.driver.window_handles:
        self.driver.switch_to.window(handle)
        if matcher(self._get_current_window_info()):
            return
    if starting_handle:
        self.driver.switch_to.window(starting_handle)
    raise WindowNotFound(error)