Repository: godotengine/godot (C++)

Issue:
`find_children` returns `[]` if match string is given
### Godot version

v4.0.alpha13.official [59dcddc45]

### System information

Windows 11, Nvidia GeForce GTX 1050, 27.21.14.5771

### Issue description

`find_children` method of `Node` returns empty list even if it is looking for a node with a name is present in the tree! 
It finds the node if the `match_string` is `"*"`.


### Steps to reproduce
```
find_children("*name*", "", true, true)  # returns []
find_children("*") # returns [nodes! whoohoo!]
```

### Minimal reproduction project
[MRP.zip](https://github.com/godotengine/godot/files/9231350/MRP.zip)


FindChildren not finding nested children
### Godot version

4.0.1-stable_mono_win64

### System information

Windows 10 19044

### Issue description

I'm writing a C# script and trying to use `FindChildren` in my `_Ready` method.

My scene is like this with a root node with the script attached:

![image](https://user-images.githubusercontent.com/8959496/228436785-897dbbf3-eca6-4b3e-940c-17ada4e305e8.png)

Calling `FindChildren("face_*")` is returning an empty array where I instead expect it to return a collection of the 6 nodes under `cube_rounded`.

If I call `FindChild("face_*")` instead it properly returns the `face_front` first node at the top of the tree, so the singular child function is working, but not the collection one.

`FindChildren("Pivot")` does find its immediate child, so it looks like maybe the `recursive` property is being ignored? Explicitly setting it to `true` changes nothing.

### Steps to reproduce

1. Install C# version of Godot
2. Setup a 3D scene of nodes (any type) with hierarchy:

- RigidBody3D (names not important here)
  - Pivot
    - cube_rounded
      - face_front
      - face_left
      - face_right
      - face_back
      - face_top
      - face_bottom

3. Create a new C# script on the root node inheriting from `Node3D`
4. Add `var test = FindChildren("face_*");` in the `_Ready()` method
5. set a breakpoint in Visual Studio and debug the project

See after executing the line that test is an empty array instead of the 6 expected nodes.

Repros in 4.0.0-stable as well (checked for new version and tried on 4.0.1 when I saw it had released, same issue).

### Minimal reproduction project

Minimal project with same structure above of just Node3D objects:

[FindChildrenRepro.zip](https://github.com/godotengine/godot/files/11097185/FindChildrenRepro.zip)

Setup to output in Console:

```
--- Debugging process started ---
Godot Engine v4.0.1.stable.mono.official.cacf49999 - https://godotengine.org
Vulkan API 1.3.205 - Forward Mobile - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 1080
 
Children Count: 0 expect 6
Can find child instead: True
```

Should see `Children Count: 6 expect 6` instead.

Included the call to `FindChild` which shows the exact same pattern working to find a child there, but the aggregate call with `FindChildren` fails.


Discussion: This might be because `find_children` only searches for the children nodes whose names match the `match_string`.

![image](https://user-images.githubusercontent.com/83043568/182160007-7a729e0d-59d5-4d84-a0ae-fe3125d46637.png)

In this case, `find_children("A*","",true,true)` would returns ["A", "A/Alpha"] but not "B/Alpha".





Fix (patch):
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 22bcfc947bd4..6ca34e324c3d 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1414,25 +1414,19 @@ TypedArray<Node> Node::find_children(const String &p_pattern, const String &p_ty
 			continue;
 		}
 
-		if (!p_pattern.is_empty()) {
-			if (!cptr[i]->data.name.operator String().match(p_pattern)) {
-				continue;
-			} else if (p_type.is_empty()) {
+		if (p_pattern.is_empty() || cptr[i]->data.name.operator String().match(p_pattern)) {
+			if (p_type.is_empty() || cptr[i]->is_class(p_type)) {
 				ret.append(cptr[i]);
-			}
-		}
+			} else if (cptr[i]->get_script_instance()) {
+				Ref<Script> scr = cptr[i]->get_script_instance()->get_script();
+				while (scr.is_valid()) {
+					if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == scr->get_path()) || p_type == scr->get_path()) {
+						ret.append(cptr[i]);
+						break;
+					}
 
-		if (cptr[i]->is_class(p_type)) {
-			ret.append(cptr[i]);
-		} else if (cptr[i]->get_script_instance()) {
-			Ref<Script> scr = cptr[i]->get_script_instance()->get_script();
-			while (scr.is_valid()) {
-				if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == scr->get_path()) || p_type == scr->get_path()) {
-					ret.append(cptr[i]);
-					break;
+					scr = scr->get_base_script();
 				}
-
-				scr = scr->get_base_script();
 			}
 		}