handle subqueries in the AST