When looking at http://www.w3.org/TR/html4/struct/global.html#h-7.5.5, just inline elements are allowed inside headings, so h2 isn't allowed inside another h2 (or other heading). So jTidy finds an error and tries to fix this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note : I am using jtidy-r938
I'm not sure nesting h2 elements is allowed. That's probably why it is failing.
When looking at http://www.w3.org/TR/html4/struct/global.html#h-7.5.5, just inline elements are allowed inside headings, so h2 isn't allowed inside another h2 (or other heading). So jTidy finds an error and tries to fix this.