Can you clarify in a comment what will happen to heading levels > 3?

FWIW I refactored a bit to understand the `+2` (maybe it's useful)?

    headings = ['h1', 'h2', 'h3']
    level = headings.indexOf($el[0].nodeName.toLowerCase()
    # Pick up all elements until the next heading of the same level or higher
    selector = headings.slice(0, level).join(',')