I understand that when WordPress is about to require a template file, it checks several files in order, e.g. page-$id.php, page-$slug.php, page.php, index.php (for a page request), each in the child theme first, then in the parent theme.
Question: is there an API to get the list of candidates that will be checked for the current query?
I want to use this list to generate a similar list to use with locate_template() for small blocks that are in separate files. For example, if I have a menu, and the request is a page request, I want these files tried: parts/menu-page-$id.php, parts/menu-page-$slug.php, parts/menu-page.php, parts/menu.php. And I want this to mimic the behavior of WordPress template hierarchy for all kinds of requests (page/archive/category/taxonomy/single, etc.) but without me reimplementing the whole logic.