<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_rml_def(self, location_type, location, filename=None, **kwargs):
 """ Registers the rml file locations for easy access Args: ----- location_type: ['package_all', 'package_file', 'directory', 'filepath'] location: The correlated location string based on the location_type filename: Optional, associated with 'package_file' location_type kwargs: ------- include_subfolders: Boolean """

        if location_type == 'directory':
            self.register_directory(location, **kwargs)
        elif location_type == 'filepath':
            if not os.path.exists(location):
                raise OSError("File not found", location)
            if os.path.isfile(location):
                self.register_rml(location)
            elif filename:
                new_loc = os.path.join(location, filename)
                if not os.path.exists(new_loc):
                    raise OSError("File not found", new_loc)
                elif os.path.isfile(new_loc):
                    self.register_rml(new_loc)
            else:
                raise OSError("File not found", location)
        elif location_type.startswith('package'):
            pkg_path = \
                    importlib.util.find_spec(\
                            location).submodule_search_locations[0]
            if location_type.endswith('_all'):
                self.register_directory(pkg_path, **kwargs)
            elif location_type.endswith('_file'):
                filepath = os.path.join(pkg_path, filename)
                self.register_rml(filepath, **kwargs)
            else:
                raise NotImplementedError