def METHOD_NAME(me, cutoff = 0.02, nbones = 4):
    """Remove vertices from vertex group if their weight is less than cutoff.
    The affected vertices are selected in editmode for further inspection if
    required.
    Returns number of vertices affected."""
    num_affected = 0
    # deselect all vertices
    for v in me.vertices:
        v.sel = 0
    # remove weights
    for group in me.getVertGroupNames():
        # skip body parts
        if group.startswith("BP_"):
            continue
        print(f"=== {group} ===")
        vert_list = me.getVertsFromGroup(group, 1) # second argument = 1 means also return vertex weights
        remove_list = [v[0] for v in vert_list if v[1] < cutoff]
        me.removeVertsFromGroup(group, remove_list)
        num_affected += len(remove_list)
        # inform user
        if remove_list:
            print("removed due to low weight")
            print(remove_list)
        # select affected vertices
        for i in remove_list:
            me.vertices[i].sel = 1
    for vert in me.vertices:
        influences = me.getVertexInfluences(vert.index)
        # skip body parts
        influences = [infl for infl in influences
                      if not infl[0].startswith("BP_")]
        if len(influences) > nbones:
            # sort by weight
            influences.sort(key=lambda infl: infl[1], reverse=True)
            # remove the ones with lowest weight
            for group, weight in influences[nbones:]:
                me.removeVertsFromGroup(group, [vert.index])
                vert.sel = 1
                num_affected += 1
                print(f"removed {vert.index} ({weight:.3f}) from {group}")
    return num_affected