Cyclisation reaction through hydrazine The following reaction confuses me - I don't understand how and why it happened (couldn't figure out the mechanism):



I thought this is some Wolff Kishner sort of reduction, but the reagents don't match (no alkaline medium). I am not sure how hydrazine lead to cyclisation - for starters, I guess it added to the carbonyl oxygen (aldehyde, as it is more reactive) as an ammonia derivative to form a hydrazone. What's next?
It's essentially just the same reaction once and then over again. The basic medium of the Wolf-Kishner reduction is to remove the hydrazone hydrogen, releasing the $\ce{C=N}$ electrons onto the carbon. In this reaction, the hydrazone instead further reacts with the other carbonyl to form an aromatic 6-membered ring.