There's a high percentage of identical files and folders in the storage and we want to compact it. As a solution we decided to find all identical folder structures, deduplicate and create symbolic links to the only copy.
2 folders are identical if they contain an identical set of files and subfolders. 2 files are identical if they have the same name.

In the example above folder bar/baz/boo is identical to bar/fizz/buzz and foo/boo; also bar/baz is identical to foo. Write a program to de-duplicate identical structures on the disk.
How would you solve this?