Optimizred collectNodes