Another idea (which heavily depends on what you are viewing [single or archive] and also your taxonomy-structure) is to look for the term parent.
Maybe this can help you aswell …
You were asking about “highest category in the hierarchy for a specific post”.
Example:
A post is associated with 3 terms of an taxonomy which are hierachical:
Parent Term
-First-Child Term
--Second-Child Term
You could get all the associated terms of this post:
$all_terms = get_the_terms( $post_id, $taxonomy );
And than find the term which has a parent of 0:
foreach($all_terms as $term) {
if($term->parent == 0){
//here you have the data of the topmost parent, e.g. "Parent Term"
// get parent term ID
$parent_id = $term->term_id;
// get term obj from ID to get term name
$parent_obj = get_term_by( 'id', $parent_id, $taxonomy );
// show parent term name
echo $parent_obj->name; // "Parent Term"
// show parent term permalink URL
echo = get_term_link( $parent_id );
}
}
As you see, this will only work if the post has only one parent and than child-terms assiciated. For other setups this will not work!