public function setParents(array $parents)
    {
        $ownclass = get_class($this);
        $is_root = ($this->id === static::$root);

        $this->parents = array();
        foreach ($parents as $parent)
        {
            if (is_object($parent) && get_class($parent) == $ownclass)
                $this->parents[$parent->id] = $parent;
            elseif (is_scalar($parent))
                $this->parents[$parent] = null;
            else
                throw new Exception("Parent-ID must be a " . $ownclass . " object or a scalar");
        }

        if (empty($this->parents) && !$is_root)
            $this->parents = [$this->getRoot()];

        return $this;
    }