using "find data" aka "extract selection" with python scripting

I posted about this recently myself (I searched but did find this thread):
https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182

But I was able to figure out the code needed because I found out that the query selection is caught by an incremental trace.

I was using 5.9.0 RC3.