Validate node nesting structure

This solution feels a little gross to me, but I haven't been able to come up with anything better.

Fixes #101.