You can pull out the tree for the dictionary and sift it.
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('VOCABULARY_NAME', 0);
for ($tree as $term) {
if (in_array($termId, $term->parents)) {
$parent_term = $term;
break;
}
}
source
share