One source of the problem is that WorkingTreeIterator.isModified() is 
doing much. Why should we ever want a content comparison in the idBuffer() method? If we detect by metadata comparison that we cannot reuse the index-entry id we want to simply compute the content-id() on the file-content (and don't compare it with the content of the index entry).
I suggest that we introduce a new comparison method on WorkingTreeIterator which compares only the metadata of the entry and a index entry. That method will be reused in the isModified() method and will be called from idBuffer(). 

All this will remove the infinite recursion problem. I'll post such a proposal and rebase this change on it.