def db_add(model, key_name, parent=None, **kwargs):
    """
    This function creates an object transactionally if it does not exist in
    the datastore. Otherwise it returns None.
    """
    existing = model.get_by_key_name(key_name, parent=parent)
    if not existing:
        new_entity = model(parent=parent, key_name=key_name, **kwargs)
        new_entity.put()
        return new_entity
    return None