In the non-recursive case, we have to set up a watcher for each subdirectory of the root. So we traverse the root, looking for directories to watch or unwatch. Since the root can also be a single file instead of a directory, we test for that case in the second disjunct. (It's a little roundabout because when you visit a file, only that file is visited.)