I am using the code off this page: https://www.wpbeginner.com/wp-tutorials/how-to-display-child-taxonomy-on-parent-taxonomys-archive-page/
However my Custom taxonomy has more depth for cities, state, country.
I need "if ($term->parent == 0)" to search for if term has child, then do this, else then do this. Right now, parent taxonomy displays it's parent children, but I need parent taxonomy display it's children taxonomies and children taxonomy displays parents children. In essence both parent and child taxonomies would display the same cities if you understand what I mean on their respective pages.
So you goto Michigan page(parent), it displays Boston, Detroit, Grand Rapids etc. If you goto Boston page(child), it would still display Boston, Detroit, Grand Rapids etc. because there are no more children.
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
if ($term->parent == 0) {
wp_list_categories('taxonomy=YOUR-TAXONOMY-NAME&depth=1&show_count=0
&title_li=&child_of=' . $term->term_id);
} else {
wp_list_categories('taxonomy=YOUR-TAXONOMY-NAME&show_count=0
&title_li=&child_of=' . $term->parent);
}
?>