You could have a fold priority value associated with each fold level, with users able to set their own priority to folding.
This could allow you to set folding for certain keywords on a by priority basis, for example
for could be associated with a lower priority. Then the depth of folding would fold to a specific priority level/depth as opposed to some arbitrary level.
I recently submitted this
Request and this post caught my eye.
Looking at the src though, it seems the folding is irrespective of the context of the braces, in my mind the braces represent a context or grouping which should have association. Not given it much thought though.