private function determineMapFor(int $index, int $parentId, array $inverseList): ?int
    {
        if (!isset($inverseList[$parentId])) {
            throw new \InvalidArgumentException(
                'Page id ' . $parentId . ' has not been mapped'
            );
        }

        // Lookup all children of parent page in main language.
        $mainSiblings = $this->database->getPagesByPidList([$inverseList[$parentId]]);

        return isset($mainSiblings[$index]) ? (int) $mainSiblings[$index]['id'] : null;
    }