PREFIX : select ?x ?y where { ?x :p ?y OPTIONAL { ?y :q ?z} filter( ! exists {?y :q ?z }) }