Yeah that makes sense, `invariant(childNode.nextSibling != null)` should be sufficient and simple I think. As for the variable, tricky yes, my current naming was intended to reflect the idea that it's just a different implementation of the same behavior as `insertBefore` (insert X before node Y), perhaps `index` should rather be renamed to `beforeIndex` which could add some sense to `beforeNode` (which is just locally caching the value), possibly?