public function findPidOfMainTableRecord(string $tableName): int
    {
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
        $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
        $row = $queryBuilder->select('uid')
            ->from('pages')
            ->where(
                $queryBuilder->expr()->eq(
                    'tx_styleguide_containsdemo',
                    $queryBuilder->createNamedParameter($tableName, \PDO::PARAM_STR)
                )
            )
            ->orderBy('pid', 'DESC')
            ->execute()
            ->fetch();
        if (count($row) !== 1) {
            throw new Exception(
                'Found no page for main table ' . $tableName,
                1457690656
            );
        }
        return (int)$row['uid'];
    }