(maint) don't duplicate CTE for inactive nodes
(maint) don't duplicate CTE for inactive nodes

Only apply the CTE to non-subqueries.

rbrw/puppetdb,mullr/puppetdb,mullr/puppetdb,mullr/puppetdb,rbrw/puppetdb,rbrw/puppetdb,rbrw/puppetdb,rbrw/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb,mullr/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb,puppetlabs/puppetdb,mullr/puppetdb