Fix NPE is PatternNode.toString if it's root