Generalized recursion into traverseRecursively