### Godot version

4.1

### System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 30.0.15.1403) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

### Issue description


https://github.com/godotengine/godot/assets/2223172/852654b0-dadd-411e-8fe5-f9c00492a497



### Steps to reproduce

1. Add a Node to the scene
2. Right click it and mark it as unique name
3. Start renaming the node
4. Press Enter

### Minimal reproduction project

N/A
for (int i = 0; i < p_terms.size(); i++) {
		String term = p_terms[i];
		// Recognize special filter.
		if (term.contains(":") && !term.get_slicec(':', 0).is_empty()) {
			String parameter = term.get_slicec(':', 0);
			String argument = term.get_slicec(':', 1);
			if (parameter == "type" || parameter == "t") {
				// F
				String type = get_node(p_item->get_metadata(0))->get_class();
				bool term_in_inherited_class = false;
				// E
				while (type != "Node") {
					if (type.to_lower().contains(argument)) {
						term_in_inherited_class = true;
						break;
					}
					type = ClassDB::get_parent_class(type);
				}
				if (!term_in_inherited_class) {
					return false;
				}
			} else if (parameter == "group" || parameter == "g") {
				// F
				Node *node = get_node(p_item->get_metadata(0));
				if (argument.is_empty()) {
					// W
					if (node->get_persistent_group_count() == 0) {
						return false;
					}
				} else {