Fixes #1364 in Python by using ast.NodeTransformer
Mitigates #1364 in R by raising exception after a given level of recursion. This does not fix the issue, but avoids getting in an endless while loop. When ast is implemented for R, we can adopt the same approach as in Python.
ast.NodeTransformer