Improved iterator for nested categories