The determination of the list of paths can be achieved much simpler - see the attached patch.
mmph... why can't I remove an attachment? I have added a second change, which is not subject of this issue.
If the second change you added isn't in the commit acb6447c963d
, please open a new ticket with the second patch.
Thank you very much for your contribution!