default <E extends Document> Optional<E> getDocument(Class<E> clazz) {
        requireNonNull(clazz);
        if (clazz.isAssignableFrom(Translator.this.getDocument().mainInterface())) {
            @SuppressWarnings("unchecked")
            final E result = (E) Translator.this.getDocument();
            return Optional.of(result);
        }

        return Translator.this.getDocument()
            .ancestors()
            .filter(clazz::isInstance)
            .map(clazz::cast)
            .findAny();
    }
Returns this node or one of the ancestor nodes if it matches the
specified {@code Class}. If no
such node exists, an {@code Optional.empty()} is returned.

@param <E> the type of the class to match
@param clazz the class to match
@return the node found
generator-parent/generator-translator/src/main/java/com/speedment/generator/translator/Translator.java