recursive implementation

a recursive implementation of sanity for python3