how to show only last child terms of a taxonomy

I wanted to display the terms with the get_the_term_list function so, since categories & taxonomy have a “similar logic”, I replaced the “the_category_list”

add_filter( 'the_category_list', 'ci_theme_the_category_list_remove_parent_categories', 10 );

with
“get_the_terms”

add_filter( 'get_the_terms', 'only_last_taxonomy_terms', 10 );

and it does what I need.