protected function getRelation($entity, $method)
    {
        // We need to check the relationship method only at the first local entity, because all entities must be of the same class.
        if (!method_exists($entity, $method)) {
            throw new LogicException('Call to undefined relationship "' . $method . '" on model "' . get_class($entity) . '".');
        }

        // Create a Relation without any constrains.
        $relation = \Core\Models\Relation::noConstraints(function() use ($entity, $method) {
            return $entity->$method();
        });

        if (!$relation instanceof Relation) {
            throw new LogicException('Relationship method "' . $method . '" must return an object of type Core\Models\Contracts\Relation.');
        }

        return $relation;
    }