public static ULocale getHighestAncestorLocale()

in locales-utils/src/main/java/com/spotify/i18n/locales/utils/hierarchy/LocalesHierarchyUtils.java [99:111]


  public static ULocale getHighestAncestorLocale(final ULocale locale) {
    Preconditions.checkNotNull(locale);
    Preconditions.checkArgument(
        !isSameLocale(locale, ULocale.ROOT), "Param locale cannot be the ROOT.");
    ULocale highestAncestor = locale;
    while (true) {
      Optional<ULocale> currentOpt = getParentLocale(highestAncestor);
      if (currentOpt.get().equals(ULocale.ROOT)) {
        return highestAncestor;
      }
      highestAncestor = currentOpt.get();
    }
  }