in inlined in the function above, the nodesToRevist field can be cached as local var