def METHOD_NAME(paths: Union[str, List[str]], target: Optional[str] = None) -> Set[str]:
    """
    Get the app paths from ttfw_idf under the given paths
    """
    from idf_build_apps import CMakeApp
    cases = get_ttfw_cases(paths)
    res: Set[str] = set()
    for case in cases:
        if not target or target == case.case_info['target'].lower():
            # ttfw has no good way to detect the app path for master-slave tests
            # the apps real location may be the sub folder of the test script path
            # check if the current folder is an app, if it's not, add all its subfolders if they are apps
            # only one level down
            _app_dir = case.case_info['app_dir']
            if CMakeApp.is_app(_app_dir):
                res.add(_app_dir)
            else:
                for child in os.listdir(_app_dir):
                    sub_path = os.path.join(_app_dir, child)
                    if os.path.isdir(sub_path) and CMakeApp.is_app(sub_path):
                        res.add(sub_path)
    return res