What are the best practices for optimizing the performance of recursive functions in programming?