public function findVersions(Query $query, array $options)
    {
        $association = $this->versionAssociation();
        $name = $association->getName();

        return $query
            ->contain([$name => function (Query $q) use ($name, $options, $query) {
                if (!empty($options['primaryKey'])) {
                    $foreignKey = (array)$this->_config['foreignKey'];
                    $aliasedFK = [];
                    foreach ($foreignKey as $field) {
                        $aliasedFK[] = "$name.$field";
                    }
                    $conditions = array_combine($aliasedFK, (array)$options['primaryKey']);
                    $q->where($conditions);
                }
                if (!empty($options['versionId'])) {
                    $q->where(["$name.version_id IN" => $options['versionId']]);
                }
                $q->where(["$name.field IN" => $this->_fields()]);

                return $q;
            }])
            ->formatResults([$this, 'groupVersions'], $query::PREPEND);
    }