@Nullable
  private static Value getOptionalValue(@NotNull Value optionalTrace) {
    if (!(optionalTrace instanceof ArrayReference trace)) {
      throw new UnexpectedValueTypeException("optional trace must be an array value");
    }

    if (!optionalIsPresent(trace)) {
      return null;
    }

    final Value value = trace.getValue(1);
    if (value instanceof ArrayReference) {
      return ((ArrayReference)value).getValue(0);
    }

    throw new UnexpectedValueTypeException("unexpected format for an optional value");
  }
@Nullable
  private static Value getOptionalValue(@NotNull Value optionalTrace)