I don't think you are handling all cases there. What if both children are null pointers? Then the else clause will fail. In the case where they are both non-null, you'll probably also want to sum the singeParent() results for each, rather than just the left side. Not sure if this will fix your problem though.