protected function makeSubjectsArrayForPPN($parentPPN)
    {
        $rootNodes = $this->queryForChildrenOf($parentPPN);
        $subjects = [];

        while ($nodeRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($rootNodes)) {
            $subject = [];

            // Add PPN for separating distinct subject fieldsets
            $subject['id'] = strtolower($nodeRecord['ppn']);

            // Use English subject name if it exists and the language is English
            // and the German subject name otherwise.
            if ($GLOBALS['TSFE']->lang == 'en' && $nodeRecord['descr_en']) {
                $subject['name'] = $nodeRecord['descr_en'];
            } else {
                $subject['name'] = $nodeRecord['descr'];
            }

            // Recursively add child elements if they exist.
            if ($nodeRecord['childcount'] > 0) {
                $subject['subjects'] = $this->makeSubjectsArrayForPPN($nodeRecord['ppn']);
            }

            // Extract each search term from the 'search' field and add an array with all of them.
            if ($nodeRecord['search'] != '') {
                $searchComponents = [];
                foreach (explode(' or ', urldecode($nodeRecord['search'])) as $searchComponent) {
                    $component = trim($searchComponent, ' *');
                    $component = preg_replace('/^LKL /', '', $component);
                    $searchComponents[] = trim($component);
                }
                $subject['queries'] = $searchComponents;
            } else {
                $subqueries = [];
                foreach ($subject['subjects'] as $subsubject) {
                    foreach ($subsubject['queries'] as $subquery) {
                        $subqueries[] = $subquery;
                    }
                }
                $subject['queries'] = $subqueries;
            }

            // Add tag fields to subject (inline and break).
            foreach (explode(',', $nodeRecord['tags']) as $tag) {
                if ($tag != '') {
                    $subject[$tag] = true;
                }
            }

            $subjects[] = $subject;
        }

        return $subjects;
    }