Implement tree version.