SI-8239 don't loop forever in ContextTrees.locateContextTree

Made loop invariant / recursion metric explicit.

review by @dragos, as no good bug-reporting deed goes unpunished