Looking at https://github.com/dandi/dandi-cli/blob/HEAD/dandi/upload.py#L430, the O complexity doesn't matter much besides if I do smth like _bids_discover_and_validate(glob('openneuro/*')) it could eventually cost some CPU cycles, but overall goal is not clear to me there: are we trying to identify "root" BIDS datasets, or what?
whatever we find the reason to be for that code, if warranted, should provide a comment in the code on the purpose. But may be we could just avoid that O(N^2) looping through all possible combinations of bids datasets paths.