Convert a DOM element tree into a JSON object representation that captures the type, props, and children.
Asked in frontend interviews at Google, Amazon, Flipkart and 1 more