finish tree implementation