The code for mapping directory hierarchies is written in Python and can be found below.
It uses a Root class to map the files and directories in any chosen directory, and then creates Directory classes for each directory found. The Directory classes then do the same for the directory they were created for. The resulting data structure preserves the hierarchy of the real directory.