<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect_directories(self, directories):
 """ Collects all the directories into a `set` object. If `self.recursive` is set to `True` this method will iterate through and return all of the directories and the subdirectories found from `directories` that are not blacklisted. if `self.recursive` is set to `False` this will return all the directories that are not balcklisted. `directories` may be either a single object or an iterable. Recommend passing in absolute paths instead of relative. `collect_directories` will attempt to convert `directories` to absolute paths if they are not already. """

        directories = util.to_absolute_paths(directories)

        if not self.recursive:
            return self._remove_blacklisted(directories)

        recursive_dirs = set()
        for dir_ in directories:
            walk_iter = os.walk(dir_, followlinks=True)
            walk_iter = [w[0] for w in walk_iter]
            walk_iter = util.to_absolute_paths(walk_iter)
            walk_iter = self._remove_blacklisted(walk_iter)
            recursive_dirs.update(walk_iter)
        return recursive_dirs