Add recursion_guard_outer() for use in hashing mutable objects.

This is an updated PR to replace #460.