Another tree algorithm