add recursive link detection

Change-Id: Ib7ea89ec2854683630012a848abae517dc3bbf71