Python: Query an RDF graph