Fix infinite lock check

If there is a loop in the dependencies in the lockfile, it will create an infinite loop when checking if it's trusted. Marking the parent dependency before recursing doesn't look like it will affect the validity of the check, but will ensure the same dependency is not checked twice.