def resolve_name(name, module=None):
parts = name.split('<STR_LIT:.>')<EOL>parts_copy = parts[:]<EOL>if module is None:<EOL><INDENT>while parts_copy:  <EOL><INDENT>try:<EOL><INDENT>module = __import__('<STR_LIT:.>'.join(parts_copy))<EOL>break<EOL><DEDENT>except ImportError:<EOL><INDENT>del parts_copy[-<NUM_LIT:1>]<EOL>if not parts_copy:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>parts = parts[<NUM_LIT:1>:]<EOL><DEDENT>obj = module<EOL>for part in parts:<EOL><INDENT>obj = getattr(obj, part)<EOL><DEDENT>return obj<EOL>
Resolve a dotted name to a module and its parts. This is stolen
    wholesale from unittest.TestLoader.loadTestByName.