public function renderCategoryTree(
        \Twig_Environment $environment,
        $tree,
        $selectedCategory = null,
        $currentCategory = null,
        $template = null
    ) {
        if (count($tree)) {
            if ($template === null) {
                $template = $this->getTemplate();
            }

            return $environment->render(
                $template,
                [
                    'categories' => $tree,
                    'selected_category' => $selectedCategory,
                    'current_category' => $currentCategory,
                ]
            );
        }

        return null;
    }