'Resolves all dependency-relations from the given dependency, and frees
and returns dependants with no more dependencies. If the given
dependency is itself a dependant, all those relations are also removed.
>>> tracker = DependencyTracker()
>>> tracker.add(0, 1)
>>> tracker.add(0, 2)
>>> tracker.add(2, 3)
>>> tracker.resolve(0)
{1, 2}
>>> tracker.resolve(2)
{3}
>>> tracker.resolve(2)
set()
:param dependency:
The dependency.
:return:
Returns a set of dependants whose dependencies were all resolved.'

def resolve(self, dependency):

    dependencies_to_remove = []
    for (tracked_dependency, dependants) in self._dependency_dict.items():
        if (dependency in dependants):
            dependants.remove(dependency)
            if (not dependants):
                dependencies_to_remove.append(tracked_dependency)
    for tracked_dependency in dependencies_to_remove:
        del self._dependency_dict[tracked_dependency]
    possible_freed_dependants = self._dependency_dict.pop(dependency, set())
    non_free_dependants = set()
    for possible_freed_dependant in possible_freed_dependants:
        for dependants in self._dependency_dict.values():
            if (possible_freed_dependant in dependants):
                non_free_dependants.add(possible_freed_dependant)
                break
    return (possible_freed_dependants - non_free_dependants)
