    def _switch_to_nearest_vertical_widget(self, direction):
        """
        Find the nearest widget above or below the current widget with the focus.

        This should only be called by the Frame when normal Layout navigation fails and so this needs to find
        the nearest widget in the next available Layout.  It will not search the existing Layout for a closer
        match.

        :param direction: The direction to move through the Layouts.
        """
        # If no current widget, just find next one
        current_widget = self._layouts[self._focus].get_current_widget()
        if current_widget is None:
            self._find_next_tab_stop(direction)
            return

        # Otherwise, find the nearest option
        focus = self._focus
        focus += direction
        while self._focus != focus:
            if focus < 0:
                focus = len(self._layouts) - 1
            if focus >= len(self._layouts):
                focus = 0
            match = self._layouts[focus].get_nearest_widget(current_widget, direction)
            if match:
                self.switch_focus(self._layouts[focus], match[1], match[2])
                return
            focus += direction
Find the nearest widget above or below the current widget with the focus.

This should only be called by the Frame when normal Layout navigation fails and so this needs to find
the nearest widget in the next available Layout.  It will not search the existing Layout for a closer
match.

:param direction: The direction to move through the Layouts.
asciimatics/widgets/frame.py