How to tell if a page has subpages for Custom Post Types

This code will return an array with IDs of all pages having sub pages. Hope you were looking for it 🙂

$args = array(
    'post_type' => 'page',
    'post_status' => 'publish'
);
$parentPages = array(); // an empty array to store pages with childs
$pages = get_pages($args); 
// Looping through all pages and then we'll check for the pages with child
foreach($pages as $page) {
    if($page->post_parent != 0){ // checking if the page has any parent
        // checking if parent page isn't in our array already
        if(!in_array($page->post_parent, $parentPages)) { 
            array_push($parentPages, $page->post_parent);
        }
    }
}
print_r($parentPages);