Binary Search Tree Hackerrank Sql