<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_to_sys_modules(mod_name, mod_obj=None):
 """Add a module object to `sys.modules`. @param mod_name: module name, used as key to `sys.modules`. If `mod_name` is `a.b.c` while modules `a` and `a.b` are not existing, empty modules will be created for `a` and `a.b` as well. @param mod_obj: a module object. If None, an empty module object will be created. """

    mod_snames = mod_name.split('.')

    parent_mod_name = ''

    parent_mod_obj = None

    for mod_sname in mod_snames:
        if parent_mod_name == '':
            current_mod_name = mod_sname
        else:
            current_mod_name = parent_mod_name + '.' + mod_sname

        if current_mod_name == mod_name:
            current_mod_obj = mod_obj
        else:
            current_mod_obj = sys.modules.get(current_mod_name, None)

        if current_mod_obj is None:
            current_mod_obj = imp.new_module(current_mod_name)

        sys.modules[current_mod_name] = current_mod_obj

        if parent_mod_obj is not None:
            setattr(parent_mod_obj, mod_sname, current_mod_obj)

        parent_mod_name = current_mod_name

        parent_mod_obj = current_mod_obj