Functional binary tree iterator