
I have to find out all the leaf nodes of this graph with a generic query, this is because the leaf node is getting created from item X after 2 steps in some cases, in 1 step in some cases and in 3 steps in some cases.
Can someone help to write a generic RDF traversal query?