Added final code.

Duplicity of nodes taken into account.