def get_or_create(session, model, **kwargs):
    """
    Determines if a given record already exists in the database.

    Args:
        session: The database session.
        model: The model for the record.
        **kwargs: The properties to set on the model. The first
            specified property will be used to determine if
            the model already exists.

    Returns:
        Two values. The first value is a boolean
        indicating if this item is a new record. The second
        value will be the created/retrieved model.
    """
    instance = session.query(model).filter_by(**kwargs).first()
    if instance:
        return False, instance
    else:
        instance = model(**kwargs)
        return True, instance