Restore execution states only when returning from a recursive call