Add validation for child nodes.

Since a Query node should have children, if it has zero children it
has encountered an error generating the tree, in this cicrumstance
the query should be aborted and nil returned.