def METHOD_NAME(test, decorator):
    """
    Decorate all test cases in C{test} with C{decorator}.
    C{test} can be a test case or a test suite. If it is a test suite, then the
    structure of the suite is preserved.
    L{decorate} tries to preserve the class of the test suites it finds, but
    assumes the presence of the C{_tests} attribute on the suite.
    @param test: The C{TestCase} or C{TestSuite} to decorate.
    @param decorator: A unary callable used to decorate C{TestCase}s.
    @return: A decorated C{TestCase} or a C{TestSuite} containing decorated
        C{TestCase}s.
    """
    try:
        tests = iter(test)
    except TypeError:
        return decorator(test)
    # At this point, we know that 'test' is a test suite.
    _clearSuite(test)
    for case in tests:
        test.addTest(METHOD_NAME(case, decorator))
    return test