Can you query for elements between multiple children in a parent-child join?

Is it possible to query among the elements of children and return the parent. So if one child has a gender of male and age of 17 and another has a gender of female and age of 21. Is it possible to return the parents if and only if they have a male child and a child whose age is 21?