I am not able to break out of this C++ recursive function when the condition is met, I believe due to the fact that the for loop continues. Is there a way to break out of the en