flatten traverse