Fix to prevent stackless traversal from getting stuck in circular neighbor references.