Allow nested directories

Recursively makes queries for all subdirectories, storing each directory as a sub-object
The indentation is difficult to read here.