'Return a DependencyMap containing all of this spec\'s
dependencies with their constraints merged.
If copy is True, returns merged copies of its dependencies
without modifying the spec it\'s called on.
If copy is False, clears this spec\'s dependencies and
returns them.'

def flat_dependencies(self, **kwargs):

    copy = kwargs.get('copy', True)
    deptype_query = kwargs.get('deptype_query')
    flat_deps = {}
    try:
        deptree = self.traverse(root=False, deptype_query=deptype_query)
        for spec in deptree:
            if (spec.name not in flat_deps):
                if copy:
                    spec = spec.copy(deps=False)
                flat_deps[spec.name] = spec
            else:
                flat_deps[spec.name].constrain(spec)
        if (not copy):
            for spec in flat_deps.values():
                spec._dependencies.clear()
                spec._dependents.clear()
            self._dependencies.clear()
        return flat_deps
    except UnsatisfiableSpecError as e:
        raise InconsistentSpecError(('Invalid    Spec    DAG:    %s' % e.message))
