now can handle trees