visitor: fix use-after-free in nodes hashmap