get_nodes refactor

git cherry-pick 4a50d67 from master:
Change-Id: I2242bad9d4100f5ef280fe480c0f27cf4eb079be