[SPARK-3161][MLLIB] Adding a node Id caching mechanism for training deci...

...sion trees. @jkbradley @mengxr @chouqin Please review this.
(from above)  You can just test ```useNodeIdCache``` at this line.  That should reduce code duplication.