private function downLink(Model $model, array $visited, StoreOptions $opts)
{
$statement = $this->formatModel($model);
if (in_array($model, $visited)) {
return array_slice($visited, array_search($model, $visited));
}
$visited[] = $model;
$down_ref = $this->downRef($statement, $opts);
if ($down_ref !== null) {
$refs = $this->downLink($down_ref, $visited, $opts);
$this->setRefs($statement, $refs, $opts);
$this->unQueue($model);
return array_merge([$model], $refs);
} else {
$this->unQueue($model);
return [$model];
}
}