Turn a (directed, labeled) graph into a tree (RDF->JSON).