Show a specific hierarchical level of a specific custom taxonomy

How do I adapt the following code fragment to apply to a specific custom taxonomy? Currently it applies to post categories.

I use the following function with this: in my topic files to show each level of hierarchical category

get_level function ($ category, $ level = 0)
{
if ($ category-> category_parent == 0) {
returns $ level;
} else {
$ level ++;
$ category = get_category ($ category-> category_parent);
returns get_level ($ category, $ level);
}
}

function display_cat_level ($ level = 0, $ link = false) {

$ cats = get_the_category ();
yes ($ cats) {
foreach ($ cats like $ cat) {
$ current_cat_level = get_level ($ cat);
if ($ current_cat_level == $ level) {
if ($ link == true) {
eco & # 39;