SQL: self-joins and recursion — Backend Interview Challenge | Mentoxis