Goals: Flush stats caches only in current translation project

Removing the cache in all the translation projects in the same project when
saving a translation was taking too much time.

Partially amends commit cc0ed4b4. Performance fixes in the next two commits.
Goals: Refactor out the code for getting the trail to a given path
Goals: More efficient cache flush for a given path

Now all the affected objects are retrieved before handling them. This avoids
retrieving the objects, for example the directories, several times thus
querying the database several times for the same object.