To find Under defined sketches.

Hey guys,
Hope all is well!!!

Need help on one of my requirement which is related to coding, which I am not aware of.
Could anyone please help me to get a code for the requirement as stated below ?

After completion of my Part Model, I check in the feature tree if any of the Sketches are under defined.

To check for the under defined sketches, I use the below method:

Step 1: Right click on the Top most Plane or on the feature tree manager and click on "Go To".
Step 2: In the box, type as (-) and check the box "Start from the top" option and hit on "Find Next".

Attached is the image for reference.

Using the above method, I get to know the under defined sketches at one shot.

Could anyone please help me in getting a code for the above mentioned 2 steps to check for under defined sketches ??

Thank you for your time.
Many thanks in advance.

SolidworksApi/macros