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

Made loop invariant / recursion metric explicit.