private function lookupModel(&$row)
    {
        $query = new ImportModel();

        // Set the connection and table.
        $query->setConnection($this->connection($this->argument('dataset')));
        $query->setTable(sprintf('data_%s', array_get($this->config, 'table')));

        $count_keys = 0;

        foreach (array_get($this->config, 'import_keys', []) as $key) {
            if (!is_null($value = array_get($row, $key, null))) {
                $query = $query->where($key, $value);
                $count_keys++;
            }
        }

        if ($count_keys > 0) {
            $model = $query->first();
        }

        if (is_null($model)) {
            $model = new ImportModel();
        }

        // Ensure connection and table are set.
        $model->setConnection($this->connection($this->argument('dataset')));
        $model->setTable(sprintf('data_%s', array_get($this->config, 'table')));

        return $model;
    }