Implement writeNode()