public function getRelation($name)
    {
        if (!isset($this->relationships)) {
            $relations = $this->getRelations();
        } else {
            $relations = $this->relationships;
        }

        foreach ($relations as $relation) {
            if ($relation->getAlias() == $name) {
                return $relation;
            }
        }
        return false;
    }