allow recursive dereferencing

I had an error in the `doc_type` method because the given dereferenced property was in fact itself a reference to another definition.

This simple change allows recursive dereferencing and fixes the issue.