def set_material(item, material):
    """Set the material on an item.
    
    Args:
        item (bpy.Object): The Blender object to assign the material to.
        material (bpy.Material): The material to assign.
        
    Returns:
        bpy.Material: The Blender material.
    """
    # Don't bother if we can't even apply material to object.
    if not hasattr(item.data, "materials"):
        return
    # Assign Material
    if not item.data.materials:
        # Add the material to the object
        item.data.materials.append(material)
    else:
        # If a material already exists, swap it.
        item.data.materials[0] = material
    return material