def _trimFrames(self, frames):
        newFrames = list(frames)

        if len(frames) < 2:
            return newFrames

        firstMethod = newFrames[0][0]
        firstFile = os.path.splitext(os.path.basename(newFrames[0][1]))[0]

        secondMethod = newFrames[1][0]
        secondFile = os.path.splitext(os.path.basename(newFrames[1][1]))[0]

        syncCase = (("_run", "_synctest"),
                    ("runWithWarningsSuppressed", "util"))
        asyncCase = (("maybeDeferred", "defer"),
                     ("runWithWarningsSuppressed", "utils"))

        twoFrames = ((firstMethod, firstFile), (secondMethod, secondFile))

        if _PY3:
            # On PY3, we have an extra frame which is reraising the exception
            for frame in newFrames:
                frameFile = os.path.splitext(os.path.basename(frame[1]))[0]
                if frameFile == "compat" and frame[0] == "reraise":
                    # If it's in the compat module and is reraise, BLAM IT
                    newFrames.pop(newFrames.index(frame))

        if twoFrames == syncCase:
            newFrames = newFrames[2:]
        elif twoFrames == asyncCase:
            newFrames = newFrames[3:]
        elif (firstMethod, firstFile) == ("_runCallbacks", "defer"):
            newFrames = newFrames[1:]

        if not newFrames:
            # The method fails before getting called, probably an argument
            # problem
            return newFrames

        last = newFrames[-1]
        if (last[0].startswith('fail')
            and os.path.splitext(os.path.basename(last[1]))[0] == '_synctest'):
            newFrames = newFrames[:-1]

        return newFrames
Wait until the ui object gone or exist.
dataset/ETHPy150Open twisted/twisted/twisted/trial/reporter.py/Reporter._trimFrames--crossover with--dataset/ETHPy150Open xiaocong/uiautomator/uiautomator/__init__.py/AutomatorDeviceUiObject.wait