implement generic traversal