Runtime error for RRATING

I am getting a runtime error for this solution for the problem RRATING. I am using a binary search tree to store the ratings and then an inorder traversal to find the min rating among the top 1/3 ratings. I am looking for a reason for the runtime error. Is it because I am possibly using too much memory while constructing the tree? Thanks in advance!