query for stacksizes and loop nesting