WordPress Check If Current Category Has Children

function category_has_children() {
global $wpdb;
$term = get_queried_object();
$category_children_check = $wpdb->get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term->term_id' ");
if ($category_children_check) {
return true;
} else {
return false;
}
}

<?php
if (!category_has_children()) {
//use whatever loop or template part here to show the posts at the end of the line
get_template_part('loop', 'index');
} else {
// show your category index page here
}
?>

Apply template to all child pages

<?php
$page_children = get_pages('child_of=6215');
foreach($page_children as $child){
$current_page_template = get_post_meta($child->ID,'_wp_page_template',true);
if($current_page_template != 'page-kyle.php') update_post_meta($child->ID,'_wp_page_template','page-kyle.php');
}
?>