Python Recursive Function Global Variable Cpp