add support for weighted trees