def _get_vars(cr, case_names, var_types=None):
    """
    Return a set of variable names whose values are present in at lease one of the given cases.

    Parameters
    ----------
    cr : CaseReader
        The CaseReader housing the data.
    case_names : Iterable of str
        The case_names from which the outputs with available residuals out are to be returned.
    var_types : None or Iterable of str
        The type of variables to be returned.
        Either 'inputs', 'outputs', or None for both inputs and outputs.

    Returns
    -------
    list
        A list of the variables available in at least one of the given cases.
    """
    vars = set()
    for case_name in case_names:
        case = cr.get_case(case_name)
        if var_types is None or 'outputs' in var_types:
            case_outputs = case.list_outputs(prom_name=True, units=False, shape=False,
                                             val=True, residuals=False, out_stream=None)
            vars |= {meta['prom_name'] for abs_path, meta in case_outputs}
        if var_types is None or 'inputs' in var_types:
            case_inputs = case.list_inputs(prom_name=True, units=False, shape=False,
                                           val=True, out_stream=None)
            vars |= {meta['prom_name'] for abs_path, meta in case_inputs}
    return sorted(list(vars))