Zend certified PHP/Magento developer

How to delete file/folder with specific names only if there is another file with certain extension in that folder with PowerShell?

As a developer, I have many bin and obj folders that I would like to cleanup to reclaim some space. I can use this script:

Get-ChildItem . -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }

However, to be safe, I only want to delete them if in the folder that contains bin or obj folder, there is a file with .csproj or .sln extension. Is it possible?