How to implement trampolines for tail calls in Python