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

...sion trees. @jkbradley @mengxr @chouqin Please review this.
I agree it could get deep quickly, and switching indexing systems seems good for a future PR.  (W.r.t. training without pruning, I suspect it would be better and more efficient to use outright nearest neighbor since completely unpruned trees are basically doing nearest neighbor.)