def METHOD_NAME(obj):
    if len(obj.data.vertices) == 0:
        return obj
    obj = separate_loose(obj)
    with butil.ViewportMode(obj, 'EDIT'):
        bm = bmesh.from_edit_mesh(obj.data)
        bm.verts.ensure_lookup_table()
        bm.edges.ensure_lookup_table()
        included = np.zeros(len(bm.verts))
        i = min((v.co[-1], i) for i, v in enumerate(bm.verts))[1]
        queue = [bm.verts[i]]
        included[i] = 1
        to_keep = []
        while queue:
            v = queue.pop()
            for e in v.link_edges:
                o = e.other_vert(v)
                if not included[o.index]:
                    included[o.index] = 1
                    to_keep.append(e)
                    queue.append(o)
        bmesh.ops.delete(bm, geom=list(set(bm.edges).difference(to_keep)), context='EDGES')
        bmesh.update_edit_mesh(obj.data)
    return obj