Memoization(caching calls)
Keep each answer a recursive function already computed in a cache, so a repeated call returns the stored value instead of recomputing the same tree.
Keep each answer a recursive function already computed in a cache, so a repeated call returns the stored value instead of recomputing the same tree.