Fix recursive dependency handling and detect properly if a specified
dependency was located.