a quick fix for finding eponymous parents

Fixes Issue #1039.
A naive implementation that assumes no homonymic collision in one directory.
Just copied from my local workaround patch.