Exists (query directive)
Includes rows where the inner directive returns a non-empty result using the row itself as input.
Note that the condition directive in If evaluates to true if it returns a non empty set. Thus it is usually unnecessary to wrap it inside an Exists directive.
importPackage(org.wandora.query2); new Instances() .where(new Exists(new Instances()))
This selects all instances of the input topic which have instances of their own.