I'm not sure how to do that via REST.
There is ?query parameter that you can send along with HTTP GET request to a ALM REST resource to filter entities.
You can read about it in RESt API reference guide in ALM's help.
But there is a problem.
You can't do it like that
http://<YOU ALM SERVER>:<port>/qcbin/rest/domains/ALEX_K/projects/sql/tests?query={Subject[^Subject\1^]}
It will say test doesn't have field "subject"
We have that field in ALM when we set filter - but it appears there is no such field for a test, heh...
So there is parent-id field - that tells you what is Id of a parent folder.
Request like this wiil work - http://<YOU ALM SERVER>:<port>/qcbin/rest/domains/ALEX_K/projects/sql/tests?query={parent-id[1001]}
BUT if you have something like I do:
You will se only 2 tests, because only tests 1 and are under folder 1 - that has id = 1001, the tests of a child folders will be ignored - because obviously those tests have DIFFERENT parent-id's because they are deeper in a hierarchy.
Of course I can browse through all that folders in a hierarchy, knowing their ids. like this:
http://<YOU ALM SERVER>:<port>qcbin/rest/domains/ALEX_K/projects/sql/tests?query={parent-id[1001 or 1002 or 1003 or 1004 or 1005]}
And I will see all of my 6 tests, but what if I had like 100 folders under 1 root folder in a hierarchy?
That would be a nightmare ;)
P.S. there is another resource
http://<YOU ALM SERVER>:<port>/qcbin/rest/domains/ALEX_K/projects/sql/test-folders/
So I guess you can create your own solution combining requests to test folder figuring out your structure, id's and stuff, and then you can use that info to add a filter when you'll look for tests in a tets resource...