use reduce-kv for pre/postwalk