Dynamic trees for learning and design