def get_controller_object(controller):
    """
    Get the object associated with a controller, or None if there's no object,
    which is usually a group.
    """
    controller_objects = controller.controllerObject.listConnections(s=True, d=False)
#    controller_objects = pm.ls(cmds.listConnections(unicode(controller.controllerObject), s=True, d=False))
    return controller_objects[0] if controller_objects else None