DP with trees