fix handling of duplicate entries in tree (fixes #7)