1class Solution:2def getDirections(3self, root: Optional[TreeNode], startValue: int, destValue: int4) -> str:5def find(n: TreeNode, val: int, path: List[str]) -> bool:6if n.val == val:7return True8if n.left and find(n.left, val, path):9path += "L"10elif n.right and find(n.right, val, path):11path += "R"12return path1314s, d = [], []15find(root, startValue, s)16find(root, destValue, d)17while len(s) and len(d) and s[-1] == d[-1]:18s.pop()19d.pop()20return "".join("U" * len(s)) + "".join(reversed(d))