A graph database would be a natural fit for a tree structure. In Neo4j you could represent files and folders very simply like this:
(:Folder)-[:CONTAINS]->(:File)
(:Folder)-[:CONTAINS]->(:Folder)
If you then wanted to compare structures, you could make two cypher queries
MATCH path=(top_folder:Folder)-[:CONTAINS*1..15]->(leaf)
WHERE
ID(top_folder) = {specified_id}
(leaf:File OR leaf:Folder) AND
NOT(leaf-[:CONTAINS]->())
RETURN path
This would give you back all of the paths of the directory structure starting at the folder that you specify which you could then compare.
Alternatively if you're comfortable with Java (or some language with Java integration), you can use the built-in Neo4j APIs to build your own recursive algorithms to compare the structures.