Figured out how to use SPARQL with named graphs in Redland/Virtuoso. Replacing former kludgy list_trees method with new version.