Add some optimization around registered node query

Optimize by retrieving all resources at once and repeatedly using
the result, rather than retrieving all resources multiple times.

Change-Id: I31fe5b03307c9c0da2cdc14506369c54c652b36d
Merge "Add some optimization around registered node query"