refactor include / exclude operations in query hierarchy