generalized traverse, used in more places