def previous(self) -> None:
        """Switch up in the window list"""
        win = None
        if self._focused:
            win = self._nodes[self._focused].get_prev_window()
        if not win:
            win = self._tree.get_last_window()
        if win:
            self.group.focus(win.window, False)
        self._focused = win.window if win else None
Switch up in the window list
libqtile/layout/tree.py