Unrolled loop query

This addresses Bug #7809

The remaining use of uploadtree is unfortunately unavoidable as it tries to find out if the decision is made on the same upload.

I created a new pull request  where I have unrolled the loop  for the licenses in the decision. We have made good experiences with this kind of performance optimizations.