Fix O(N^2) slowdown in initial tree traversal using nextSibling/prevSibling
Fix O(N^2) slowdown in initial tree traversal using nextSibling/prevSibling

We assigned the _index field using Array#indexOf for each child in turn,
leading to an O(N^2) running time for initially setting _index.  We cache
the _index value, so later tree traversals would remain O(N) as expected.

We could bail out of the update as soon as we (1) had seen the node whose
index needed an update and (2) saw a successor node with a correct index,
but by that time we've traversed O(N) elements anyway (assuming that the
arbitrary node is on average in the middle of the child list), so we
might as well just do the O(N) work to renumber all the children,
and avoid having to do complicated checks in the common case.

fgnass/domino,cscott/domino,fgnass/domino,arlolra/domino,cscott/domino,arlolra/domino