reparentNodes = (container, start, end = null, before = null) => {
    while (start !== end) {
        const n = start.nextSibling;
        container.insertBefore(start, before);
        start = n;
    }
}
Reparents nodes, starting from `start` (inclusive) to `end` (exclusive),
into another container (could be the same container), before `before`. If
`before` is null, it appends the nodes to the container.