Avoid dependency loops in roots command

Current implementation of roots command will ignore all packages
in dependency loop because each of them is a dependence of another package

This change fixes this by breaking loop.