def METHOD_NAME(user_input_modules=None, profile=None):
    import itertools
    existing_modules = list(itertools.chain(get_core_modules_paths_with_tests(profile),
                                            get_command_modules_paths_with_tests(profile)))
    if user_input_modules is not None:
        selected_modules = set(user_input_modules)
        extra = selected_modules - set([name for name, _, _ in existing_modules])
        # don't count extensions as extras
        extra = [x for x in extra if not x.startswith('azext_')]
        if any(extra):
            print('ERROR: These modules do not exist: {}.'.format(', '.join(extra)))
            return None
        return list((name, module, test) for name, module, test in existing_modules
                    if name in selected_modules)
    else:
        return list((name, module, test) for name, module, test in existing_modules)