Några mindre ändringar av Quassnois svar, och det fungerar:
WITH
hier1 (id, parent) AS (
SELECT id, parent
FROM table
WHERE id = @user1
UNION ALL
SELECT id, parent
FROM table l, hier1 h
WHERE l.id = h.parent
),
hier2 (id, parent) AS (
SELECT id, parent
FROM table
WHERE id = @user2
UNION ALL
SELECT id, parent
FROM table l, hier1 h
WHERE l.id = h.parent
)
SELECT TOP 1 hier1.id
FROM hier1, hier2
WHERE hier1.id = hier2.id