Trained trees are often exported as nested dicts. Each internal node is
{"feature": j, "threshold": t, "left": ..., "right": ...} (go left when x[j] <= t), and each leaf is {"value": v}.
Implement:
predict_one(tree, x): walk from the root to a leaf (iteratively, so very deep trees don't hit the recursion limit)predict(tree, X): a list of predictionsdepth(tree): number of edges on the longest root-to-leaf path (a lone leaf has depth 0)