Seems to be to do with index of postfixToTree going out of range, as depth does not hit 0 when expected.