Some code to split trees into parts.