[TIMOB-13247] Fixed issue where nodes would be both skipped and visited