function render(parent, data) {
        var collapsed = false
        var container = createList(collapsed)

        data.forEach(function (d) {
            createEl(d, container)
        })

        // Return if no TOC element is provided or known.
        tocElement = parent || tocElement
        if (tocElement === null) {
            return
        }

        // Remove existing child if it exists.
        if (tocElement.firstChild) {
            tocElement.removeChild(tocElement.firstChild)
        }

        // Just return the parent and don't append the list if no links are found.
        if (data.length === 0) {
            return tocElement
        }

        // Append the Elements that have been created
        return tocElement.appendChild(container)
    }
Render nested heading array data into a given element.
@param {HTMLElement} parent Optional. If provided updates the {@see tocElement} to match.
@param {Array} data
@return {HTMLElement}