added option indicating whether empty elements should be collapsed