If is huge (say, ), the space might be tight. You can improve by only storing up[v][j] for up to the depth of . For example, if has depth , you only need up[v][0] through up[v][2] (since ). This saves space in shallow trees.
But for most problems, the standard space is fine. Only optimize when the memory limit is tight and the tree is known to be shallow.