The castle of Toompea is a castle on Toompea hill, in the old town of Tallinn, opposite the cathedral of Aleksandr Nevskij. The name was also used ancient times to define the entire territory of Tallinn during Danish domination in the 13th and 14th centuries. The first castle, which was made of wood (from some Finnish sources is called Kesoniemi), is thought to have been built on the hill of Toompea between the X and the XI century, by residents of the ancient Estonian region of Rävala (Revalia). It was probably one of the first inhabited areas of ancient Tallinn (Reval). In 1219, the fortress was occupied by the Danish crusaders, led by Valdemaro II. According to a popular Danish legend, the old Danish flag (Dannebrog) fell from the sky during Lyndanisse's tough battle, better known as Reval's battle, fought close to the castle, thus giving Danish victory over the Estonians. The Danes later began calling Lyndanisse with the name Castrum Danorum ("The Danish Castle"). From a hypothesis the name was then translated into Estonian as Taani (n) castle, later abbreviated to Tallinn. The castle, mostly rebuilt and from which stands the tower of Ermanno the Long (in Estonian: Pikk Hermann), on whose summit fiercely flames the Estonian flag, still dominates Toompea. She is currently home to the Parliament of Estonia. Since 1991 it has been restored.