protected function renderRecursiveTree($node, $tag, Callable $render)
    {
        $out = '';
        $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">';
        foreach ($node->children as $child) {
            if (!empty($child->children)) {
                $level     = $render($child);
                $nextLevel = $this->renderRecursiveTree($child, $tag, $render);
                $out .= preg_replace('/{sub-tree}/', $nextLevel, $level);
            } else {
                $out .= preg_replace('/{sub-tree}/', '', $render($child));
            }
        }
        return $out . '</' . $tag . '>';
    }