def METHOD_NAME(val):
    if val is None:
        return None
    l = dataset.find(val)
    # If we didn't find the language, either raise an error or return the provided value
    if l is None:
        if fail_if_not_found is True:
            raise ValueError("Unable to find iso code for language {x}".format(x=val))
        else:
            return val
    # Retrieve the correct output format from a successful match
    for f in output_format:
        v = l.get(f)
        if v is None or v == "":
            continue
        return v.upper()