def get_or_create_module_r(module_name, base_module=None):
    '''Return a base-module (e.g. 'theno') or a sub-module (e.g.
    'theno.service.raccoon') from the dict addon_modules given by param
    'module_name'.

    If the highest module (e.g. 'theno') not exists, an empty module will be
    created.  This will be continued recursively until the lowest sub-module
    exists which will be returned

    Param 'base_module' is used for recursion only.
    '''
    module_names = module_name.split('.', 1)
    if len(module_names) > 1:
        # e.g. ['theno', 'service.wallabag']
        highest_module_name, module_name_rest = module_names
        highest_module = get_or_create_module_r(highest_module_name,
                                                base_module)
        if base_module:
            # anchor highest_module to its direct base-module
            base_module.__dict__[highest_module_name] = highest_module
        return get_or_create_module_r(module_name_rest,
                                      base_module=highest_module)
    else:  # len(module_names) == 0
        # module name does not contain any '.', e.g.: 'service'
        module = addon_modules.setdefault(module_name,
                                          imp.new_module(module_name))
        if base_module:
            # anchor module to its direct base-module
            base_module.__dict__[module_name] = module
        return module