def METHOD_NAME(path, module, level):
    module_file = os.path.sep.join(module.split("."))
    # if relative import
    if level:
        relative_path = path
        deep = level - 1
        for number in range(deep):
            relative_path = os.path.dirname(relative_path)
        if os.path.isfile(os.path.join(relative_path, module_file + ".py")):
            return os.path.join(relative_path, module_file + ".py")
        else:
            return os.path.join(relative_path, module_file, "__init__.py")
    # elif bazarr dir + module.py isfile
    elif os.path.isfile(os.path.join(bazarr_directory, module_file + ".py")):
        return os.path.join(bazarr_directory, module_file + ".py")
    # elif bazarr dir + module isdir
    elif os.path.isdir(os.path.join(bazarr_directory, module_file)):
        return os.path.join(bazarr_directory, module_file, "__init__.py")
    # elif libs dir + module.py isfile
    elif os.path.isfile(os.path.join(libs_directory, module_file + ".py")):
        return os.path.join(libs_directory, module_file + ".py")
    # elif libs dir + module isdir
    elif os.path.isdir(os.path.join(libs_directory, module_file)):
        return os.path.join(libs_directory, module_file, "__init__.py")
    # else base module
    else:
        return None