do not leak reference when iterating branches