'Get a list of filetypes that is either directed or indirected
extended by given base filetypes.
Note that the returned list include the root filetype itself.'

def get_deep_extends(self, base_filetypes):

    seen = set(base_filetypes)
    todo_fts = list(set(base_filetypes))
    while todo_fts:
        todo_ft = todo_fts.pop()
        unseen_extends = set((ft for ft in self._extends[todo_ft] if (ft not in seen)))
        seen.update(unseen_extends)
        todo_fts.extend(unseen_extends)
    return seen
