Preventing SystemStackError

In some cases we are encountering a problem with SystemStackErrors when there is infinite recursion. Typically this comes about when there is a known class which descends from itself and the ancestor tree is walked.

I have created a failure in the rails4 test app but the failure is a hard crash. I took a stab at writing a failsafe for recursion on the ancestor checks but it is creating other failures and I am having trouble sorting them out.

Any ideas on how to get this PR in better shape?

Thanks!