Because this serializer is invoked quite often, it would even be better to create a static node factory. I am updating my snippet above and will remove this comment when done.