function closure for tree test