Map square-tree
Extracted a function to map over a tree from square-tree (2.30)