def delete_until_zero(session, match, params=None, limit=2000):
    """Delete chunks of matches until no matches.

    Deletes in chunks of limit.

    :param session: Neo4j driver session.
    :type session: neo4j.v1.session.BoltSession
    :param match: Match query clause of a neo4j query
    :type match: str
    :param params: Neo4j query parameters.
    :type params: dict|None
    :param limit: Number of items to delete at a time.
        When deleting nodes with large numbers of relationships,
        consider making this smaller.
    :type limit: int
    :return: The number of deleted nodes.
    :rtype: int
    """
    if params is None:
        params = {}

    total_deleted = 0
    deleted = 1

    # Alter query for deleting in chunks
    cipher = [
        match,
        'WITH n LIMIT {}'.format(limit),
        'DETACH DELETE n',
        'RETURN count(*) as `deleted`'
    ]
    cipher = ' '.join(cipher)

    # Keep going until 0.
    while deleted > 0:
        with session.begin_transaction() as tx:
            resp = tx.run(cipher, **params)
            deleted = resp.single()['deleted']
            total_deleted += deleted
    return total_deleted