Maybe not the greatest approach to the solution, but you could just add WITH MAXRECURSION = 365 query hint. Recursion is limited to ~32,000 calls.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning