You can show nested data in the details section of the Data View control. Read about it here: Data Views – Part 10: Nested Repeat in the Detail Section.
In case you have a ‘flat’ Data View (one without collapisble categories) you do not need to detect if your ‘var’ property is a document. But when you have a categorized Data View you better check it otherwise opening/closing categories will give an error…