Great catch... it is used though.  categoryNames holds some kind of working list of categories seen so far, and uniqueCategories is the final return value. 

That said, I think the logic here could probably be simplified.