### Godot version

v4.0.beta.custom_build [0abd60b95]

### System information

Windows 10, Vulkan

### Issue description

Autocomplete doesn't work when trying to access a scene node that isn't a direct child of the scene root script, using $NodePath (Shorthand for get_node("NodePath") as per docs).

Example:
![image](https://user-images.githubusercontent.com/115422160/212197922-10e73c9f-de10-475e-ac6e-4163fc5b8013.png)

It worked in Godot 3.5:
![3.5](https://user-images.githubusercontent.com/115422160/212197992-61b67a42-86c6-4650-bab4-c7dfa5a67975.PNG)

I should mention that it works if you start by typing the name of a direct child:
![image](https://user-images.githubusercontent.com/115422160/212198641-6d8e6fca-a2d2-47a7-b627-2df95268daf5.png)

But when you have many nodes in the scene and longer names it's a pain to access the last children like that.


### Steps to reproduce

See above or MRP.

### Minimal reproduction project

[autocomplete bug.zip](https://github.com/godotengine/godot/files/10406695/autocomplete.bug.zip)

switch (p_what) {
		case NOTIFICATION_THEME_CHANGED:
		case NOTIFICATION_ENTER_TREE: {
			style_normal = get_theme_stylebox(SNAME("normal"));
			font = get_theme_font(SNAME("font"));
			font_size = get_theme_font_size(SNAME("font_size"));
			line_spacing = get_theme_constant(SNAME("line_spacing"));
			set_gutter_width(main_gutter, get_line_height());
			set_gutter_width(line_number_gutter, (line_number_digits + 1) * font->get_char_size('0', font_size).width);
			set_gutter_width(fold_gutter, get_line_height() / 1.2);
			breakpoint_color = get_theme_color(SNAME("breakpoint_color"));
			breakpoint_icon = get_theme_icon(SNAME("breakpoint"));
			bookmark_color = get_theme_color(SNAME("bookmark_color"));
			bookmark_icon = get_theme_icon(SNAME("bookmark"));
			executing_line_color = get_theme_color(SNAME("executing_line_color"));
			executing_line_icon = get_theme_icon(SNAME("executing_line"));
			line_number_color = get_theme_color(SNAME("line_number_color"));
			folding_color = get_theme_color(SNAME("code_folding_color"));
			can_fold_icon = get_theme_icon(SNAME("can_fold"));
			folded_icon = get_theme_icon(SNAME("folded"));
			code_completion_max_width = get_theme_constant(SNAME("completion_max_width"));
			code_completion_max_lines = get_theme_constant(SNAME("completion_lines"));
			code_completion_scroll_width = get_theme_constant(SNAME("completion_scroll_width"));
			code_completion_scroll_color = get_theme_color(SNAME("completion_scroll_color"));
			code_completion_scroll_hovered_color = get_theme_color(SNAME("completion_scroll_hovered_color"));
			code_completion_background_color = get_theme_color(SNAME("completion_background_color"));
			code_completion_selected_color = get_theme_color(SNAME("completion_selected_color"));