result = Sequence.EMPTY;
} else {
result = sequence.getItem(1);
for (int i = 2; i <= sequence.getLength(); i++) {
Value currentItem = sequence.getItem(i);
CompareResult compareResult = PipelineExpressionHelper.compare(
result, currentItem);
if (compareResult == getExtremeValueComparisonResult()) {
result = currentItem;
} else if (compareResult == CompareResult.INCOMPARABLE) {
if (result instanceof NumericValue && currentItem instanceof NumericValue) {