code: public static function findFirstActiveByMemberGroups($arrIds)
  	{
  		if (empty($arrIds) || !\is_array($arrIds))
  		{
  			return null;
  		}
  
  		$time = Date::floorToMinute();
  		$objDatabase = Database::getInstance();
  		$arrIds = array_map('\intval', $arrIds);
  
  		$objResult = $objDatabase->prepare("SELECT p.* FROM tl_member_group g LEFT JOIN tl_page p ON g.jumpTo=p.id WHERE g.id IN(" . implode(',', $arrIds) . ") AND g.jumpTo>0 AND g.redirect='1' AND g.disable!='1' AND (g.start='' OR g.start<='$time') AND (g.stop='' OR g.stop>'" . ($time + 60) . "') AND p.published='1' AND (p.start='' OR p.start<='$time') AND (p.stop='' OR p.stop>'" . ($time + 60) . "') ORDER BY " . $objDatabase->findInSet('g.id', $arrIds))
  								 ->limit(1)
  								 ->execute();
  
  		if ($objResult->numRows < 1)
  		{
  			return null;
  		}
  
  		$objRegistry = Registry::getInstance();
  
  		/** @var PageModel|Model $objPage */
  		if ($objPage = $objRegistry->fetch('tl_page', $objResult->id))
  		{
  			return $objPage;
  		}
  
  		return new static($objResult);
  	}
docs: Find the first active page by its member groups
  
  @param string $arrIds An array of member group IDs
  
  @return PageModel|null The model or null if there is no matching member group