Ah. I just realized that one of the things I got hung up on was: what if in your string of edits, you get something like (new element) (deleted element) (new element) (existing element)? I was worried that the first new element would end up with the wrong position, because the deleted element would still exist in the tree, and that first element would get inserted after it. But it doesn't matter because we're going to delete that element anyway.