Python is not Scheme, it can't optimize tail calls.  Use explicit iteration.