Search in Two level nested entities

I'm working on a search page in a website for two nested entities like class and student. the user can searches for specific students like students that has these two sets of properties:

gender=male
Height=short

The user can also add other criteria and searches for specific classes that have some students with this properties:

gender=female
Height=long

and

gender=male
Weight<50

sample screenshot

So the question is: Have I over complicated the search with this combination?

Is there any other design for support the combination of search in this two level nested entities?

Any feedback would be greatly appreciated.