map_dfs function

Apply a function to nodes in the order of a depth first search