def prioritized_iter(cls, flag_val, env_val, config_val, config_default_val,
                       hardcoded_val, default):
    """Yield the non-None values from highest-ranked to lowest, wrapped in RankedValue instances."""
    if flag_val is not None:
      yield RankedValue(cls.FLAG, flag_val)
    if env_val is not None:
      yield RankedValue(cls.ENVIRONMENT, env_val)
    if config_val is not None:
      yield RankedValue(cls.CONFIG, config_val)
    if config_default_val is not None:
      yield RankedValue(cls.CONFIG_DEFAULT, config_default_val)
    if hardcoded_val is not None:
      yield RankedValue(cls.HARDCODED, hardcoded_val)
    yield RankedValue(cls.NONE, default)
Yield the non-None values from highest-ranked to lowest, wrapped in RankedValue instances.