How to get the URL of a sitemap that contains a certain post?

I achieved it using this simple query

<?php

$chunks=array_chunk(
  get_posts([
    'fields'=>'ids',
    'posts_per_page'=>-1,
    'post_type'=>[$post->post_type],
    'orderby'=>'ID',
    'order'=>'ASC'
  ]),
  wp_sitemaps_get_max_urls('post')
);

foreach($chunks as $key => $chunk) {
  if(!in_array($post->ID,$chunk)) continue;

  var_dump(get_sitemap_url('posts',$post->post_type,$key + 1));
  break;
}

tech