def createOverwriteItem(gc, parentFolderId, name):
    """
    Creates an item, overwriting it if it already existed.

    :param gc: Instance of GirderClient with the correct permissions.
    :param parentFolderId: The parent folder of the item.
    :param name: The name of the item to create.
    :returns: The newly created item.
    :rtype: dict
    """
    toDelete = gc.listItem(parentFolderId, name=name)

    for item in toDelete:
        gc.delete('item/%s' % item['_id'])

    return gc.createItem(parentFolderId, name)