Circular reference detection

A basic way of avoiding stack overflows with circular references in a
type hierarchy. Looks a bit messy but I have a feeling it can be
refactored into something nicer. Related to #20
If a child has a property of the root target type I wanted to catch that as well, as it would also result in recursion. Should've put in a unit test specifically for it.