protected function _hasReference($c, $link, $defaults = []) : Reference
    {
        if (!is_array($defaults)) {
            $defaults = ['model' => $defaults ?: 'Model_'.$link];
        } elseif (isset($defaults[0])) {
            $defaults['model'] = $defaults[0];
            unset($defaults[0]);
        }

        $defaults[0] = $link;

        $obj = $this->factory($c, $defaults);

        // if reference with such name already exists, then throw exception
        if ($this->hasElement($name = $obj->getDesiredName())) {
            throw new Exception([
                'Reference with such name already exists',
                'name'     => $name,
                'link'     => $link,
                'defaults' => $defaults,
            ]);
        }

        return $this->add($obj);
    }