I guess you want to check if the active page is a) of your custom post type and b) one of the ancestors is your parameter.
First of all, i would advise you to keep on using the ID, as slugs and titles can be non-unique, so one slug could be different posts.
Second, you can use wordpress’ own get_post_ancestors
-function. Use it like this:
function wpse365743_has_ancestor($postid,$ancestor_id){
//get all parents and ancestors of $postid
$ancestors = get_post_ancestors($postid);
//add in the current post id
$ancestors = array_merge(array($postid),$ancestors);
//is the searched ancestor id in the ancestors?
return in_array($ancestor_id,$ancestors);
}
You can now use this anywhere on your page like this:
if(('my_post_type_name' == get_post_type($check_post_id)) && wpse365743_has_ancestor($check_post_id,$searched_ancestor_id)){
//do something
}
Happy Coding!