public static function toRecord($data, RecordInterface $root = null)
    {
        $visitor   = new RecordSerializeVisitor($root);
        $traverser = new GraphTraverser();
        $traverser->traverse($data, $visitor);

        return $visitor->getObject();
    }