Repository: godot
Issue: Gizmo `get_material` editor crash: `ERROR: Parameter "data.tree" is null.`
Labels: bug,topic:editor,crash

### Tested versions

Reproducible in:
- v4.4.dev.custom_build [88197d4a5]
- v4.3.stable.official [77dcf97d8]
- v4.0.stable.official [92bee43ad]

### System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 980 Ti (NVIDIA; 31.0.15.3598) - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)

### Issue description

Calling `get_material` on a gizmo's `_redraw` can cause a crash if the call to `_redraw` happens at a specific time. It crashes with the error message:
```
ERROR: Parameter "data.tree" is null.
   at: Node::get_tree (C:\Personal\Godot\godot_src\scene/main/node.h:471)

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.4.dev.custom_build (88197d4a513a7873cb7cf85138a42a04fb1c9011)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] SceneTree::get_edited_scene_root (C:\Personal\Godot\godot_src\scene\main\scene_tree.cpp:1449)
[1] EditorNode3DGizmo::is_editable (C:\Personal\Godot\godot_src\editor\plugins\node_3d_editor_gizmos.cpp:45)
[2] EditorNode3DGizmoPlugin::get_material (C:\Personal\Godot\godot_src\editor\plugins\node_3d_editor_gizmos.cpp:1016)
[3] call_with_validated_variant_args_ret_helper<EditorNode3DGizmoPlugin,Ref<StandardMaterial3D>,String const &,Ref<EditorNode3DGizmo> const &,0,1> (C:\Personal\Godot\godot_src\core\variant\binder_common.h:375)
[4] call_with_validated_object_instance_args_ret<EditorNode3DGizmoPlugin,Ref<StandardMaterial3D>,String const &,Ref<EditorNode3DGizmo> const &> (C:\Personal\Godot\godot_src\core\variant\binder_common.h:663)
[5] MethodBindTR<EditorNode3DGizmoPlugin,Ref<StandardMaterial3D>,String const &,Ref<EditorNode3DGizmo> const &>::validated_call (C:\Personal\Godot\godot_src\core\object\method_bind.h:538)
[6] GDScriptFunction::call (C:\Personal\Godot\godot_src\modules\gdscript\gdscript_vm.cpp:2108)
[7] GDScriptInstance::callp (C:\Personal\Godot\godot_src\modules\gdscript\gdscript.cpp:2035)
[8] Object::callp (C:\Personal\Godot\godot_src\core\object\object.cpp:789)
[9] Variant::callp (C:\Personal\Godot\godot_src\core\variant\variant_call.cpp:1211)
[10] GDScriptFunction::call (C:\Personal\Godot\godot_src\modules\gdscript\gdscript_vm.cpp:1783)
[11] GDScriptInstance::callp (C:\Personal\Godot\godot_src\modules\gdscript\gdscript.cpp:2035)
[12] Node::_gdvirtual__process_call<0> (C:\Personal\Godot\godot_src\scene\main\node.h:376)
[13] Node::_notification (C:\Personal\Godot\godot_src\scene\main\node.cpp:56)
[14] Node::_notificationv (C:\Personal\Godot\godot_src\scene\main\node.h:50)
[15] Node3D::_notificationv (C:\Personal\Godot\godot_src\scene\3d\node_3d.h:52)
[16] Object::notification (C:\Personal\Godot\godot_src\core\object\object.cpp:876)
[17] SceneTree::_process_group (C:\Personal\Godot\godot_src\scene\main\scene_tree.cpp:1023)
[18] SceneTree::_process (C:\Personal\Godot\godot_src\scene\main\scene_tree.cpp:1100)
[19] SceneTree::process (C:\Personal\Godot\godot_src\scene\main\scene_tree.cpp:582)
[20] Main::iteration (C:\Personal\Godot\godot_src\main\main.cpp:4329)
[21] OS_Windows::run (C:\Personal\Godot\godot_src\platform\windows\os_windows.cpp:1781)
[22] widechar_main (C:\Personal\Godot\godot_src\platform\windows\godot_windows.cpp:181)
[23] _main (C:\Personal\Godot\godot_src\platform\windows\godot_windows.cpp:206)
[24] main (C:\Personal\Godot\godot_src\platform\windows\godot_windows.cpp:220)
[25] WinMain (C:\Personal\Godot\godot_src\platform\windows\godot_windows.cpp:234)
[26] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[27] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================
```



### Steps to reproduce

1. Open MRP
2. Add a `Node3D` to the scene
3. Delete the newly added `Node3D`

### Minimal reproduction project (MRP)

[Gizmo-crash.zip](https://github.com/user-attachments/files/16839457/Gizmo-crash.zip)