Moved writeNodes() to be a Collection method.