### 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)

const int icon_hsep = get_theme_constant(SNAME("h_separation"), SNAME("ItemList"));
				const Size2 icon_area_size(row_height, row_height);
				code_completion_rect.size.width = code_completion_longest_line + icon_hsep + icon_area_size.width + 2;
				code_completion_rect.size.height = lines * row_height;
				const Point2 caret_pos = get_caret_draw_pos();
				const int total_height = csb->get_minimum_size().y + code_completion_rect.size.height;
				const bool can_fit_completion_above = (caret_pos.y - row_height > total_height);
				const bool can_fit_completion_below = (caret_pos.y + row_height + total_height <= get_size().height);
				if (!can_fit_completion_below && can_fit_completion_above) {
					code_completion_rect.position.y = (caret_pos.y - total_height - row_height) + line_spacing;
				} else {
					code_completion_rect.position.y = caret_pos.y + (line_spacing / 2.0f);
					code_completion_below = true;
				}
				const int scroll_width = code_completion_options_count > code_completion_max_lines ? code_completion_scroll_width : 0;
				const int code_completion_base_width = font->get_string_size(code_completion_base, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
				if (caret_pos.x - code_completion_base_width + code_completion_rect.size.width + scroll_width > get_size().width) {
					code_completion_rect.position.x = get_size().width - code_completion_rect.size.width - scroll_width;
				} else {
					code_completion_rect.position.x = caret_pos.x - code_completion_base_width;
				}
				draw_style_box(csb, Rect2(code_completion_rect.position - csb->get_offset(), code_completion_rect.size + csb->get_minimum_size() + Size2(scroll_width, 0)));
				if (code_completion_background_color.a > 0.01) {
					RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(code_completion_rect.position, code_completion_rect.size + Size2(scroll_width, 0)), code_completion_background_color);
				}
				code_completion_scroll_rect.position = code_completion_rect.position + Vector2(code_completion_rect.size.width, 0);
				code_completion_scroll_rect.size = Vector2(scroll_width, code_completion_rect.size.height);
				code_completion_line_ofs = CLAMP((code_completion_force_item_center < 0 ? code_completion_current_selected : code_completion_force_item_center) - lines / 2, 0, code_completion_options_count - lines);
				RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(code_completion_rect.position.x, code_completion_rect.position.y + (code_completion_current_selected - code_completion_line_ofs) * row_height), Size2(code_completion_rect.size.width, row_height)), code_completion_selected_color);
				for (int i = 0; i < lines; i++) {