Get into editor, open up the debug console
test = ([(configfile >> "CfgVehicles" >> "b_soldier_f"), 0, false] call BIS_fnc_returnChildren);
Press the performance test button. It should be around 16ms
Put (count test) into a watchlist to see the returned array count.
Now go into the functions editor, find the "returnChildren" function. Copy the whole test, create a custom function, and put it into an editor.
Put a if (_depth > 0) then { }; around the [_subClass,_depth - 1,_lastOnly,false] call BIS_fnc_returnChildren; line
save it, make it callable like the original one.
Test the same stuff with it.
The result should be around 3ms.
see at the (count test) watchlist, it's the same amount of config classes returned. Try it with other parameters, get more levels etc. It will be always faster with the additional if check.