Write a Polyfill for the Native getElementsByClassName() DOM Method

Implement your own version of document.getElementsByClassName() without using the native API. Given a class name string, traverse the entire DOM tree from a root node and collect all elements that contain that class in their className attribute. Handle multiple class names (space-separated), case sensitivity, and return a live-like array of matching elements. This tests deep understanding of DOM traversal algorithms and tree recursion.

Examples
Input: []
Output:
Hints

Write a Polyfill for the Native getElementsByClassName() DOM Method

Implement your own version of document.getElementsByClassName() without using the native API. Given a class name string, traverse the entire DOM tree from a root node and collect all elements that contain that class in their className attribute. Handle multiple class names (space-separated), case sensitivity, and return a live-like array of matching elements. This tests deep understanding of DOM traversal algorithms and tree recursion.