function tree(
  toc,
  tpl = /* html */ '<ul class="app-sub-sidebar">{inner}</ul>',
) {
  if (!toc || !toc.length) {
    return '';
  }

  let innerHTML = '';
  toc.forEach(node => {
    const title = node.title.replace(/(<([^>]+)>)/g, '');
    let current = `<li><a class="section-link" href="${node.slug}" title="${title}">${node.title}</a></li>`;
    if (node.children) {
      // when current node has children, we need put them all in parent's <li> block without the `class="app-sub-sidebar"` attribute
      const children = tree(node.children, '<ul>{inner}</ul>');
      current = `<li><a class="section-link" href="${node.slug}" title="${title}">${node.title}</a>${children}</li>`;
    }
    innerHTML += current;
  });
  return tpl.replace('{inner}', innerHTML);
}
Render tree
@param  {Array} toc Array of TOC section links
@param  {String} tpl TPL list
@return {String} Rendered tree