added tree functions