If the list contains NPEs then you need to sort them and then iterate over them. Use a counter to stop the iteration once you have processed the desired number of elements, for example
Hope this helps.
In the Retrieve action, choose From database, and Select your entity. Add sorting attributes as needed. In the Range, instead of All, choose Custom. Set Limit to 30 and Offset to 0. This gets you the first 30 records on the entity.
In a retrieve action, you can set the number of records you want returned. Select Custom for Range and enter the number of records you would like.
that depends on the API: if it allows you to provide a 'max' parameter or something similar, you can specify the amount of results you want.
If not, you'll have to 'trim' the list yourself. this can be done in various ways, depending on what objects you want to keep. To answer your question, yes you can do a 'Count' on the list, after which an exclusive split will allow you to activate different logic based on this count. You could for instance iterate over the list, keep a 'Counter' variable, which fills a list until it reaches 30, after which it deletes the remaining objects, that way effectively trimming your list to an amount you want.