For TextEdit, so far, as well as GoogleChrome for this OP who I copied and hacked from https://apple.stackexchange.com/users/115523/user3439894,
on Build keyboard shortcut for "minimize all windows of current app except the current window" cheers, ta,
the AppleScript, of which I know very very little
tell application "System Events" to ¬
set miniaturized of windows of application ¬
"TextEdit" whose index is not equal to 1 to true
worked ok for me
EDIT:
snarfed and adapted to get this Automator script which so far works on Mojave on Finder, TextEdit, Terminal, Preview, Opera after granting access control in System Preferences
tell application id "com.apple.SystemEvents" to tell the first process ¬
whose frontmost = true to tell a reference to windows 2 thru -1 to ¬
if exists then tell the value of attribute "AXMinimizeButton" to click
Many thanks to @CJK
Applescript - Close all windows except frontmost window