The best way to do that is exactly the way you are doing it:
for entity in map:get_entities_in_rectangle(x, y, width, height) do
if entity:get_type() == "custom_entity" and entity:get_model() == "trash" then
-- blablabla cats meow meow!
end
end
Always put the stronger condition in the outer built-in iterator, because that one is optimized. (For instance, getting first the custom entities and later the "rectangle overlapping" condition would be slightly slower). In this case you cannot do it with only 1 loop (you need to filter with "if" conditions).