def tree_walk(cls, directory, tree):
        """Walks a tree returned by `cls.list_to_tree` returning a list of
        3-tuples as if from os.walk()."""
        results = []
        dirs = [d for d in tree if d != FILE_MARKER]
        files = tree[FILE_MARKER]
        results.append((directory, dirs, files))
        for d in dirs:
            subdir = os.path.join(directory, d)
            subtree = tree[d]
            results.extend(cls.tree_walk(subdir, subtree))
        return results