Add option to return only leaves from tree traverse.