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