'Recursively list the directory, and add to the timeline.'

@flow.StateHandler()
def ProcessDirectory(self, responses):

    if responses.success:
        response = responses.First()
        if (response is None):
            return
        directory_pathspec = response.pathspec.Dirname()
        urn = directory_pathspec.AFF4Path(self.client_id)
        self.StoreDirectory(responses)
        if (self.state.first_directory is None):
            self.state.first_directory = urn
        else:
            relative_name = (urn.RelativeName(self.state.first_directory) or '')
            if (len(relative_name.split('/')) >= self.args.max_depth):
                self.Log('Exceeded    maximum    path    depth    at    %s.', urn.RelativeName(self.state.first_directory))
                return
        for stat_response in responses:
            if ((not stat_response.symlink) and stat.S_ISDIR(stat_response.st_mode)):
                self.CallClient(server_stubs.ListDirectory, pathspec=stat_response.pathspec, next_state='ProcessDirectory')
                self.state.dir_count += 1
                if ((self.state.dir_count % 100) == 0):
                    self.Status('Reading    %s.    (%d    nodes,    %d    directories    done)', urn.RelativeName(self.state.first_directory), self.state.file_count, self.state.dir_count)
        self.state.file_count += len(responses)
