flattenTree
Flattens the tree into a sequence of pairs containing each node's value and its depth.
Return
A sequence of pairs where each pair consists of a node's value and its depth in the tree.
Parameters
depth
The initial depth of the root node, default is 0.