how does get_term_by know which term to return when the same term appears twice in a hierarchical taxonomy?
get_term_by() just returns the first matching term, ‘first’ meaning some internal order in MySQL. If having multiple terms with the same name matters in your case, don’t rely on get_term_by() alone.