check if term has children drupal 8 code example
Example: taxonomy_get_children drupal 8
$children = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadChildren($entity->id());
$children = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadChildren($entity->id());