I'd not have this magic handling in the method. if the caller has a Term, they can just call getLanguageCode on it. And if this happens at a million different placed, I'd simply add a dedicated helper method for it here (though it does not happen that often).