'Interpolate intermediate directories based on their children.
This avoids us having to put in useless intermediate directories to the
client fixture.'

def BuildIntermediateDirectories(self):

    for (dirname, (_, stat)) in self.paths.items():
        pathspec = stat.pathspec
        while 1:
            dirname = os.path.dirname(dirname)
            new_pathspec = pathspec.Copy()
            new_pathspec.path = os.path.dirname(pathspec.path)
            pathspec = new_pathspec
            if ((dirname == '/') or (dirname in self.paths)):
                break
            self.paths[dirname] = (aff4_standard.VFSDirectory, rdf_client.StatEntry(st_mode=16877, st_size=1, st_dev=1, pathspec=new_pathspec))
