protected function generateTreeView($collection, $treeClass)
    {
        $content = [];

        // Generate buttons - only if not in select mode!
        if (!$this->isSelectModeActive()) {
            (new ButtonRenderer($this->environment))->renderButtonsForCollection($collection);
        }

        foreach ($collection as $model) {
            /** @var ModelInterface $model */

            $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId();

            $content[] = $this->parseModel($model, $toggleID);

            if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) {
                $template = $this->getTemplate('dcbe_general_treeview_child');
                $subHtml  = '';

                foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $childCollection) {
                    $subHtml .= $this->generateTreeView($childCollection, $treeClass);
                }

                $this
                    ->addToTemplate('select', $this->isSelectModeActive(), $template)
                    ->addToTemplate('objParentModel', $model, $template)
                    ->addToTemplate('strToggleID', $toggleID, $template)
                    ->addToTemplate('strHTML', $subHtml, $template)
                    ->addToTemplate('strTable', $model->getProviderName(), $template);

                $content[] = $template->parse();
            }
        }

        return \implode("\n", $content);
    }