Created attachment 270913[details]
[PATCH] Proposed Fix
This fixes the issue, and keyboard navigation within the DOM Tree gets fixed as well (previously when this was happened the tree would lose focus).
However I'm marking as cq- because I still fail to see how this was caused by r187496, which means there is something I don't yet fully understand here, so I want to investigate this a bit more.

> However I'm marking as cq- because I still fail to see how this was caused
> by r187496, which means there is something I don't yet fully understand
> here, so I want to investigate this a bit more.
I now understand!
The same optimization that I'm adding to moveChild(...) effectively happened before. While iterating over the child list the old code would skip over tree elements in the correct place:
> while (child) {
> var currentTreeElement = treeElement.children[treeChildIndex];
> if (!currentTreeElement || currentTreeElement.representedObject !== child) {
> ...
> }
> ...
> }
Basically we now do that first check in moveChild(...). The old code could presumably have a bug that this addresses with the correct selecting.
Either way, I'm now confident that this can land.