Sql Recursive Join Example In Python