Solve the binary search tree validation problem, and move TreeNode/ListNode to common package.