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