def _assert_param_instance(param, valid_instances):
    """check the parameter value, can be an instance of valid_instance or
    an iterable of valid_instance"""
    if isinstance(param, valid_instances):
        return
    else:
        try:
            for unique_param in param:
                if not isinstance(unique_param, valid_instances):
                    assert isinstance(unique_param, valid_instances)
        except:
            raise ValueError('%s has an invalid type' % param)
