private static function getConfigurationFromExistingTSFE($pageId, $path, $language)
    {
        if (is_int($language)) {
            GeneralUtility::_GETset($language, 'L');
        }

            /** @var $pageSelect PageRepository */
        $pageSelect = GeneralUtility::makeInstance(PageRepository::class);
        $rootLine = $pageSelect->getRootLine($pageId);

        $initializedTsfe = false;
        $initializedPageSelect = false;
        if (empty($GLOBALS['TSFE']->sys_page)) {
            if (empty($GLOBALS['TSFE'])) {
                $GLOBALS['TSFE'] = new \stdClass();
                $GLOBALS['TSFE']->tmpl = new \stdClass();
                $GLOBALS['TSFE']->tmpl->rootLine = $rootLine;
                $GLOBALS['TSFE']->sys_page = $pageSelect;
                $GLOBALS['TSFE']->id = $pageId;
                $GLOBALS['TSFE']->tx_solr_initTsfe = 1;
                $initializedTsfe = true;
            }

            $GLOBALS['TSFE']->sys_page = $pageSelect;
            $initializedPageSelect = true;
        }
            /** @var $tmpl ExtendedTemplateService */
        $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
        $tmpl->tt_track = false; // Do not log time-performance information
        $tmpl->init();
        $tmpl->runThroughTemplates($rootLine); // This generates the constants/config + hierarchy info for the template.
        $tmpl->generateConfig();

        $getConfigurationFromInitializedTSFEAndWriteToCache = $tmpl->ext_getSetup($tmpl->setup, $path);
        $configurationToUse = $getConfigurationFromInitializedTSFEAndWriteToCache[0];

        if ($initializedPageSelect) {
            $GLOBALS['TSFE']->sys_page = null;
        }
        if ($initializedTsfe) {
            unset($GLOBALS['TSFE']);
        }
        return $configurationToUse;
    }