Standard Bots Interview Question

Simple tree traversal problem. Just practice LC east and mediums.