libtracker-sparql: Handle correctly backreferences in TrackerResource tree
We do keep a notion of already visited TrackerResources when generating the output. However that could go wrong if the TrackerResource references itself or a "parent" TrackerResource.
Add the resources to the done list beforehand, so they are ensured not to be visited again if such backreferences exist.
Related: tracker-miners#60 (closed)