You can use Xpath() for those kind of questions. Xpath is a language that interrogates xml, which is actually the base of the Tree Structure in JSL.
Xpath is an independent language. You can search the internet for training for it, if you want to really use it.
Here is a simple example of finding the number of TextBoxes in a Display Tree.
Names Default To Here( 1 );
//This message applies to all display box objects
win = New Window( "test", Text Box( "my test" ) , text box("aaa"));
count=nitems(win << xpath( "//TextBox" ));
Jim