Means to count how many times a recursion was called or how to identify if all recursions were done and the code returned to the first call

I’m in need of means to check if how many times the recursive part of this function was activated to check when the first call was fulfilled, it’s part of the designed true game over that needs the first call to be fulfilled without achieving all objectives.

IEnumerator CompositeRun(string name)
{
    BotOperation operation;
    compositeOps.TryGetValue (name, out operation);
    CompositeOperation compOp = operation as CompositeOperation;
    List<BotOperation> botOpList = compOp.opList;

    if (botOpList != null)
    {
        for (int i = 0; i < botOpList.Count; i++)
        {
            BotOperation op = botOpList *;*

CompositeOperation comp = op as CompositeOperation;
if (comp != null)
{
// If this operation is a composite type, then we need to execute it first accordingly.
yield return StartCoroutine (CompositeRun(comp.name));
}
if (op != null && op.ValidateOperation(gameObject, levelDef))
{
op.RunOperation (gameObject, levelDef);
if (CheckGameOver ())
{
// If all objectives are fulfilled, then there’s no need to continue running the processes, the stage is concluded.
StopAllCoroutines ();
}
}

yield return new WaitForSeconds (operationDelay);
}
}
yield return null;
}

The standard way of denoting recursion count is to make it an argument for the function call. For example:

void MyFunction(int recursionCount, int recursionLimit)
{
	Debug.Log(string.Format("Iteration #{0} of {1}", recursionCount + 1, recursionLimit));
	if(recursionCount < recursionLimit)
	{
		MyFunction(recursionCount + 1, recursionLimit);
	}
}

void Start()
{
	MyFunction(0, 50);
}