<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def walk(self, action, user_data=None):
 """ Walk the hierarchy, applying action to each filename. Args: action: callable, the callable to invoke for each filename, will be invoked with the filename, the subfiles, and the level in the sitemap. """

        action(self.index_file, self.__root, 0, user_data)
        self.__do_walk(self.__root, 1, action, user_data)