Refined node selection logic.