ck if there are any next sibling 'ul' elements to the parent.
    var parentSiblingUlEl= selectedTocEl.parent('ul').next('ul');
    if (parentSiblingUlEl.length > 0) {
        nextTocListEl = parentSiblingUlEl.find('li:first');
    }
    if (nextTocListEl.length > 0) {
        return nextTocListEl;
    }

    //if none of the conditions are met, find the next toc list element recursively using the parent 'li' element as the
    // starting point.
    var parentListEl = selectedTocEl.parents('li:first');
    if (parentListEl.length > 0) {
        return getNextTocEl(parentListEl);
    }
    return nextTocListEl;
}

function getPreviousTocEl(selectedTocEl) {
    var prevTocListEl = [];

    // It is important that these checks are performed in this order.
    //First, check if there exists a sibling 'li' element.
    prevTocListEl = selectedTocEl.prev('li');
    if (prevTocListEl.length > 0) {
        //If a previous sibling does exist, make sure we check if the li element is expanded.
        //If the previous sibling is expanded, get the last open/visible toc list element in that subtree.
        prevTocListEl = getLastOpenTocListEl(prevTocListEl);
        return prevTocListEl;
    }

    //if a sibling li element is not found, we need to traverse the tree upwards/backwards
    // before traversing the tree up, make sure we do not have any sibling ul elments;
    var siblingUlEl = selectedTocEl.prev('ul');
    if (siblingUlEl.length > 0) {
        prevTocListEl = siblingUlEl.children('li:last');
        prevTocListEl = getLastOpenTocListEl(prevTocListEl);
    }
    if (prevTocListEl.length > 0) {
        return prevTocListEl;
    }

    // if a sibling li, ul element is not found, traverse the tree up.
    // First check if there are any previous sibling 'ul' elements to the parent.
    var parentSiblingUlEl = selectedTocEl.parent('ul').prev('ul');
    if (parentSiblingUlEl.length > 0) {
        prevTocListEl = parentSiblingUlEl.children('li:last');
        prevTocListEl = getLastOpenTocListEl(prevTocListEl);
    }
    if (prevTocListEl.length > 0) {
        return prevTocListEl;
    }

    // if the selected toc list element is the first in the list, find the parent toc list element.
    // Do not try to check if the toc list element is expanded, as that would lead to an infinite loop.
    var selectedTocElIndex = selectedTocEl.index();
    if (selectedTocElIndex === 0) {
        prevTocListEl = selectedTocEl.parents("li:first");
    }

    if (prevTocListEl.length > 0) {
        return prevTocListEl;
    }

    //if none of the conditions are met, find the previous toc list element recursively using the parent 'li' element as the
    // starting point.
    var parentListEl = selectedTocEl.parents('li:first').prev("li");
    if (parentListEl.length > 0) {
        return getPreviousTocEl(parentListEl);
    }
    return prevTocListEl;
}

function getLastOpenTocListEl(tocListEl) {
    var isExpanded = true;
    while (isExpanded) {
        if (tocListEl.hasClass('toc_expanded')) {
            tocListEl = tocListEl.children('ul:last').children('li:last');
        } else {
            isExpanded = false;
        }
    }
    return tocListEl;
}

function getSelectedTocListEl(tocEl) {
    return tocEl.find('.hovering:first').closest('li');
}

function toggleToc(tocEl) {
    if (tocEl.is(":visible")) {
        setTimeout(function () {
            tocEl.data({tocHeight:tocEl.height()})
        }, 0);
        tocEl.hide();
    } else {
        if (tocEl.data('tocHeight')) {
            var h = tocEl.data('tocHeight');
         [ZoneTransfer]
ZoneId=3
