HistoryElement () { if (selectedItem != null) { if (Comparing.equal(selectedItem.expression, myDocument.getCharsSequence())) { return selectedItem; } else { return selectedItem.changeExpression(myDocument.getText().trim()); } } assert length == 0; return selectedItem; }