Apart from trivial syntax checking, the Query Tree should be valid with respect to Object Types, i.e. OpNode of the Query Tree should have children with the same Class Index. Only Association Nodes may change the Class Index, and the change must be consistent with the Association Name.
The QT can be simplified if the nodes are not separated by an Association. Two Predicates that are hanging on a Union node can be expressed by a single Predicate where the two are OR'd (only works for distinct unions). If they are hanging on an Intersection the new Predicate will be the AND of the two. In the case of an Except there has to be a NOT operator. So a QT not containing an Association at all may be reduced to one single Predicate Tree, i.e. one Scope Query at the end. As an example, consider the tree
This can be reduced to