<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_filepath(self, filename=None, config_dir=None):
 """ Get config file. :param filename: name of config file (not path) :param config_dir: dir name prepended to file name. Note: we use e.g. GBR_CONFIG_DIR here, this is the default value in GBR but it is actually self.env_prefix + '_DIR' etc. If config_dir is not supplied it will be set to the value of the environment variable GBR_CONFIG_DIR or None. If filename is not supplied and the environment variable GBR_CONFIG is set and contains a path, its value will be tested to see if a file exists, if so that is returned as the config file otherwise filename will be set to GBR_CONFIG, if it exists, otherwise 'config.yaml'. If a filename is supplied or GBR_CONFIG is not an existing file: If the environment variable GBR_CONFIG_PATH exists the path GBR_CONFIG_PATH/config_dir/filename is checked. If it doesn't exist config/CONFIG_DIR/filename is checked (relative to the root of the (GBR) repo) finally GBR_CONFIG_DEFAULT/CONFIG_DIR/filename is tried If no file is found None will be returned. """

        # pylint: disable=no-self-use
        config_file = None
        config_dir_env_var = self.env_prefix + '_DIR'
        if not filename:
            # Check env vars for config
            filename = os.getenv(self.env_prefix, default=self.default_file)
            # contains path so try directly
            if os.path.dirname(filename) and os.path.exists(filename):
                config_file = filename
        if not config_file:
            # Cannot contain path
            filename = os.path.basename(filename)
            if not config_dir:
                config_dir = os.getenv(config_dir_env_var, default='')
            for path in [self.basepath, self.config_root]:
                filepath = os.path.join(path, config_dir, filename)
                if os.path.exists(filepath):
                    config_file = filepath
                    break
        return config_file