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

...sion trees. @jkbradley @mengxr @chouqin Please review this.
Small comment: I wonder if it would be better to check nodeIdCache.nonEmpty instead of using another value useNodeIdCache; it seems less error-prone.