For generic trees with any number of nodes.