@publisher('model')
def check_empty_groups():
    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    empty_groups = []
    for node in pm.ls(type='transform'):
        if len(node.listRelatives(children=1)) == 0:
            empty_groups.append(node)

    if len(empty_groups):
        pm.select(empty_groups)
        raise PublishError(
            'There are <b>empty groups</b> in your scene, '
            'please remove them!!!'
        )
check if there are empty groups
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/publish.py/check_empty_groups