import inspect


def get_first_nondeprecated_class(cls):
  """Get the first non-deprecated class in class hierarchy.

  For internal use only, no backwards compatibility guarantees.

  Args:
    cls: A class which may be marked as a deprecated alias.

  Returns:
    First class in the given class's class hierarchy (traversed in MRO order)
    that is not a deprecated alias.
  """
  for mro_class in inspect.getmro(cls):
    if mro_class.__name__ != '_NewDeprecatedClass':
      return mro_class