Slightly improved logic
Add support for relations more than one 'level' apart