Recoded side-chain reparenting step to fix (as far as I've been able to tell) infinite looping problems which were a bit intermittent here using the test file. The fix here involves some tighter checks to prevent corrupting the parenting of bones in the run of bones being merged but also of any ancestors of those.