'Given a sequence of path strings, return the set of all paths that
can be reached from the initial set by following symlinks.
:param paths: sequence of path strings.
:return: a sequence of path strings that are all the unique paths that
can be reached from the given ones after following symlinks.'

def symlink_closure(self, paths):

    paths = set(paths)
    closure = set()
    while paths:
        path = paths.pop()
        if (not os.path.exists(path)):
            continue
        closure.add(path)
        if os.path.islink(path):
            link_to = os.path.join(os.path.dirname(path), os.readlink(path))
            if (link_to not in closure):
                paths.add(link_to)
    return closure
