Generate a Unique CSS Selector Path for a DOM Element

Write a function that takes a DOM element as input and returns a unique CSS selector string that can be used to re-identify that exact element in the document. The selector should traverse up the DOM tree, incorporating tag names, IDs, class names, and nth-child indices to build a fully qualified and unambiguous path. This is the core of browser dev tools, test automation frameworks, and scraping utilities.

Examples
Input: []
Output:
Hints

Generate a Unique CSS Selector Path for a DOM Element

Write a function that takes a DOM element as input and returns a unique CSS selector string that can be used to re-identify that exact element in the document. The selector should traverse up the DOM tree, incorporating tag names, IDs, class names, and nth-child indices to build a fully qualified and unambiguous path. This is the core of browser dev tools, test automation frameworks, and scraping utilities.