Added a tree function to merge small branches rather than prune them.