def load_next(mod, altmod, name, buf):
if len(name) == <NUM_LIT:0>:<EOL><INDENT>return mod, None, buf<EOL><DEDENT>dot = name.find('<STR_LIT:.>')<EOL>if dot == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if dot < <NUM_LIT:0>:<EOL><INDENT>subname = name<EOL>next = None<EOL><DEDENT>else:<EOL><INDENT>subname = name[:dot]<EOL>next = name[dot+<NUM_LIT:1>:]<EOL><DEDENT>if buf != '<STR_LIT>':<EOL><INDENT>buf += '<STR_LIT:.>'<EOL><DEDENT>buf += subname<EOL>result = import_submodule(mod, subname, buf)<EOL>if result is None and mod != altmod:<EOL><INDENT>result = import_submodule(altmod, subname, subname)<EOL>if result is not None:<EOL><INDENT>buf = subname<EOL><DEDENT><DEDENT>if result is None:<EOL><INDENT>raise ImportError("<STR_LIT>" % name)<EOL><DEDENT>return result, next, buf<EOL>
mod, name, buf = load_next(mod, altmod, name, buf)

altmod is either None or same as mod