Properly cache parent/child queries and filters in the case they are wrapped in a compound filter.
Closes #2970