import warnings


def find_parameter(name, parameters_list):
    """
    Utility method to loop through parameters to find values
    etc...

    Parameters
    ----------
    name : str
        parameter name
    parameters_list : list
        list of ParameterRecord objects or ControlRecord objects

    Returns
    -------
    rec : record object

    """

    if len(parameters_list) > 0:
        for rec in parameters_list:
            if rec.name.lower() == name.lower():
                return rec
        return None

    else:
        err = "parameter_list is empty"
        warnings.warn(err, UserWarning)
        return None