Category tree rewrite