public function setClass($clazz)
    {
        if($clazz instanceof ClassMetadata)
        {
            $classMetadata = $clazz;
            $classname = $clazz->getReflectionClass()->getName();
        }
        else if (class_exists($clazz))
        {
            $classname = $clazz;
            $classMetadata = $this->getEntityManager()->getClassMetadata($clazz);
        } else
        {
            $parts = explode(':', $clazz);
            $alias = array_shift($parts);
            $rest = implode('\\', $parts);

            try
            {
                $namespace = $this->getEntityManager()->getConfiguration()->getEntityNamespace($alias);
            }
            catch (\Doctrine\ORM\ORMException $e) {
                throw new \InvalidArgumentException("Can't find class: $clazz'");
            }

            $classname = $namespace.'\\'.$rest;
            $classMetadata = $this->getEntityManager()->getClassMetadata($classname);
        }

        $reflectionClass = $classMetadata->getReflectionClass();
        if(!$reflectionClass->implementsInterface('Haven\CoreBundle\Lib\NestedSet\Node'))
        {
            throw new \InvalidArgumentException('Class must implement Node interface: ' . $classname);
        }

        $this->hasManyRoots = $reflectionClass->implementsInterface('Haven\CoreBundle\Lib\NestedSet\MultipleRootNode');
        $this->classMetadata = $classMetadata;
        $this->classname = $classname;

        return $this;
    }