This line here is ok, just be aware this logic does funny things around roots (e.g., an annotation is the last child in a paragraph). There is a wider system issue here that we'll probably need to discuss on the ML soon as to whether operations are root-aware or not.