implemented each() and stream() methods on tree