Fixes a bug when iterating on paths