[edit[edited (again) to add:] Code amended to reflect phils's suggestions in the answer below.
(defun switch-to-most-recent-buffer-in-mode (mode) (interactive "C") (let (found) (catch 'done (mapc (lambda (x) (when (with-current-buffer x (eq major-mode 'modemode)) (switch-to-buffer x) (setq found t) (throw 'done nil))) (buffer-list)) (unless found (message "not found")))))