the risk with a instance variable is that the state is quite global. you would have to be sure to empty this in all cases, including errors (e.g. by emptying it when you start the validateNodeWithType method). or could you pass it around or keep it local somewhere?

apart from that this seems the way to do it, yes.