protected function getPageIdsFromCurrentDepthAndCallRecursive(int $maxDepth, int $recursionRootPageId, array $pageIds, string $initialPagesAdditionalWhereClause = '')
    {
        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));

        $queryBuilder
            ->select('uid')
            ->from($this->table)
            ->where(
                $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($recursionRootPageId, \PDO::PARAM_INT))
            );

        $this->addDefaultLanguageUidConstraint($queryBuilder);

        if (!empty($initialPagesAdditionalWhereClause)) {
            $queryBuilder->andWhere($initialPagesAdditionalWhereClause);
        }

        $resultSet = $queryBuilder->execute();
        while ($page = $resultSet->fetch()) {
            $pageIds[] = $page['uid'];

            if ($maxDepth > 1) {
                $pageIds = array_merge($pageIds, $this->findAllSubPageIdsByRootPage($page['uid'], $maxDepth - 1));
            }
        }

        return $pageIds;
    }