def METHOD_NAME(exc: SchemaError) -> str:
    if isinstance(exc, SchemaMissingKeyError):
        return NO_QUESTIONS_ERROR_MSG.format()
    # dict.fromkeys is used for de-duplication with order preservation
    errors = {idx: msg for idx, msg in enumerate(exc.errors) if msg is not None}
    if not errors:
        return str(exc)
    error_idx, error_msg_fmt = errors.popitem()
    autos = dict.fromkeys(msg for msg in itertools.islice(exc.autos, error_idx) if msg is not None)
    keys = [match[1] for msg in autos if (match := KEY_ERROR_MSG_RE.fullmatch(msg)) is not None]
    key_count = len(keys)
    if key_count == 2:
        key = keys[-1]
        parent_key = keys[-2]
    elif key_count == 1:
        key = keys[-1]
        # should only happen for messages where this field isn't used
        parent_key = "UNKNOWN"
    else:
        # should only happen for messages where neither of the fields are used
        key = parent_key = "UNKNOWN"
    return error_msg_fmt.format(key=repr(key), parent_key=repr(parent_key))