<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getAppRefByBundleId(cls, bundleId):
 """ Get the top level element for the application with the specified bundle ID, such as com.vmware.fusion. """

        ra = AppKit.NSRunningApplication
        # return value (apps) is always an array. if there is a match it will
        # have an item, otherwise it won't.
        apps = ra.runningApplicationsWithBundleIdentifier_(bundleId)
        if len(apps) == 0:
            raise ValueError(('Specified bundle ID not found in '
                            'running apps: %s' % bundleId))
        pid = apps[0].processIdentifier()
        return cls.getAppRefByPid(pid)