I used the following to get the parent of a taxonomy term in drupal 8:
$parent = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($termId);
$parent = reset($parent);
Now that I have the parent how do I get the parent tid from that?
Now that you have the term parent with the code:
$parent = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($termId);
$parent = reset($parent);
You can simply use the $parent->id()
method to get your parent tid.