dfs helper function to populate the result vector by reference through recursion
recursively explore left and right children until we reach a leaf node
then process the current node
⌛ Complexity Analysis
Time Complexity: O(n)
Space Complexity: O(n) worst case, O(log n) best case