Added tree functionality