def check_solution(model, solution):
    """
    Helper function. if solution is None, attempts to get it from the model.

    :param model:
    :param solution:
    :return:
    """
    if solution is None:
        try:
            solution = model.solution
        except AttributeError:
            raise AttributeError('If not providing a solution object, please '
                                 'provide a model with an embedded solution '
                                 '(call model.solve())')
    return solution