MarkLogic allows organization of documents within a database using a pseudo "directory" like structure, defined by the URI used when any given document is loaded. These URIs are used to find and query documents (using fn:doc()), and to list all documents within a particular directory or subdirectory (using xdmp:directory()).
However, there doesn't appear to be any way to "view" or list all directories or subdirectories attached to documents within the database, as you would expect within a typical directory-structured filesystem. There are a few old solutions online and on SO that indicate ways to list root directories in the db, but none that allow for subdirectories, and none that work as simply as running a single piece of code to generate a full list of directories.
Is there any way to list all root and/or subdirectories within a database in MarkLogic?