Implement a basic recursive traversal function.