### Godot version

4.0 d93b66a

### System information

Windows 10 x64

### Issue description

I have a 2D scene with some 3D nodes. The root is node 2D, most nodes are 2D, I have 2D node selected. When I switch scene tab and back, the editor switches to 3D view, even though the 2D node is still selected.

I managed to strip the scene to bare minimum. You need a Node3D with Camera3D and DirectionalLight3D children.

https://user-images.githubusercontent.com/2223172/213327465-ba07760e-6dab-43c0-96e8-5109fcc0a576.mp4


### Steps to reproduce

1. Make 2D scene
2. Add some 3D
3. This bug has a chance to happen
4. Check the repro for setup that reproduces the issue

### Minimal reproduction project

[3DBug.tscn.txt](https://github.com/godotengine/godot/files/10452297/3DBug.tscn.txt)

ERR_FAIL_COND_V_MSG(p_class.is_empty(), nullptr, "Class name cannot be empty.");
	if (ScriptServer::is_global_class(p_class)) {
		String class_name = p_class;
		Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(class_name);
		while (true) {
			String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(class_name);
			Ref<Texture> icon = _load_custom_class_icon(icon_path);
			if (icon.is_valid()) {
				return icon; 
			}
			
			do {
				Ref<Script> base_scr = scr->get_base_script();
				if (base_scr.is_null()) {
					
					String base_type;
					scr->get_language()->get_global_class_name(scr->get_path(), &base_type);
					if (gui_base->has_theme_icon(base_type, "EditorIcons")) {
						return gui_base->get_theme_icon(base_type, "EditorIcons");
					}
					return gui_base->get_theme_icon(p_fallback, "EditorIcons");
				}
				scr = base_scr;
				class_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
			} while (class_name.is_empty());
		}
	}