'Filter tests with condition \'function(test_node) == True\''

@staticmethod
def _filter_tests(function, tests):

    result = {}
    for module_name in tests:
        for test_name in tests[module_name]['tests']:
            if function(module_name, test_name, tests):
                if (module_name not in result):
                    result[module_name] = {'ast': tests[module_name]['ast'], 'source_path': tests[module_name]['source_path'], 'import_valid': tests[module_name]['import_valid'], 'tests': {}}
                result[module_name]['tests'][test_name] = tests[module_name]['tests'][test_name]
    return result
