Modify query based on nested level of context selection