private Value createValue(ValueFacade expression) throws XPathException {
    final TypeHierarchy typeHierarchy = myXPathContext.getConfiguration().getTypeHierarchy();
    final ItemType itemType = expression.getItemType(typeHierarchy);

    final SequenceIterator it = expression.iterate(myXPathContext);
    GroundedValue value = null;
    if (it.next() != null) {
      value = it.materialize();
    }
    if (it.next() == null) {
      return new SingleValue(value, itemType);
    }
    return new SequenceValue(value, it, itemType);
  }
private Value createValue(ValueFacade expression)