Please, read my comment about infinite loop first.
With small changes in your data...
DECLARE @PromotionPlan TABLE(FriendID int, InvitedBy int, Vflag VARCHAR(1))
INSERT INTO @PromotionPlan(FriendID, InvitedBy, Vflag)
VALUES(1, NULL, 't'), (2, 1, 't'), (3, 2, 't'),
(4, 9, 'f'), (5, 9, 'f'), (6, 9, 't'),
(7, 5, 't'), (8, 3, 't'), (9, 3, 't'),
(10, 3, 't'), (11, 3, 't'), (12, 4, 't'),
(15, 10, 't'), (16, 10, 't'), (17, 10, 't'),
(18, 15, 't'), (19, 15, 't'), (20, 15, 't')
;WITH Ancestors AS
(
SELECT 0 AS Distance, FriendID , InvitedBy, CONVERT(varchar(MAX), CAST(FriendID AS VARCHAR(10))+ '<-' + CAST(InvitedBy AS VARCHAR(10))) AS Relation
FROM @PromotionPlan
WHERE FriendID =20
UNION ALL
SELECT Distance + 1, b.FriendID, b.InvitedBy, Relation + '<-' + CAST(b.InvitedBy AS VARCHAR(10))
FROM Ancestors a INNER JOIN @PromotionPlan b ON a.InvitedBy = b.FriendID
WHERE NOT b.InvitedBy IS NULL
)
SELECT *
FROM Ancestors
Result:
Distance FriendID InvitedBy Relation
0 20 15 20<-15
1 15 10 20<-15<-10
2 10 3 20<-15<-10<-3
3 3 2 20<-15<-10<-3<-2
4 2 1 20<-15<-10<-3<-2<-1