use visitor pattern to print node value