Fixed code because Tree.SafeIndexOp was removed from language model