getNextGroupIndex = function( index ) {
        var i = index + 1;
        while ( !groups[ i ] && i < groups.length ) {
            i++;
        }
        if ( i < groups.length ) {
            return i;
        }
    }
Get the span element from groups[] that is immediately after given index.

This can be used to find the reference node for an insertBefore() call.
If no element exists at a larger index, returns undefined. (In this case,
you'd use appendChild() instead.)

Note that index needn't itself exist in groups[].