wffweb/src/main/java/com/webfirmframework/wffweb/tag/repository/TagRepository.java
@SuppressWarnings("unchecked")
    public <T extends AbstractHtml> T findOneTagAssignableToTag(
            final boolean parallel, final Class<T> tagClass)
            throws NullValueException {

        final Collection<Lock> locks = getReadLocks(rootTags);
        for (final Lock lock : locks) {
            lock.lock();
        }

        try {
            final Stream<AbstractHtml> stream = buildAllTagsStream(parallel);

            final Optional<AbstractHtml> any = stream.filter(tag -> {
                return tagClass.isAssignableFrom(tag.getClass())
                        && !NoTag.class.isAssignableFrom(tag.getClass());
            }).findAny();

            if (any.isPresent()) {
                return (T) any.get();
            }

            return null;
        } finally {
            for (final Lock lock : locks) {
                lock.unlock();
            }
        }

    }
@SuppressWarnings("unchecked")
    public <T extends AbstractHtml> T findOneTagAssignableToTag(
            final boolean parallel, final Class<T> tagClass)
            throws NullValueException {

        final Collection<Lock> locks = getReadLocks(rootTags);
        for (final Lock lock : locks) {
            lock.lock();
        }

        try {
            final Stream<AbstractHtml> stream = buildAllTagsStream(parallel);

            final Optional<AbstractHtml> any = stream.filter(tag -> {
                return tagClass.isAssignableFrom(tag.getClass())
                        && !NoTag.class.isAssignableFrom(tag.getClass());
            }).findAny();

            if (any.isPresent()) {
                return (T) any.get();
            }

            return null;
        } finally {
            for (final Lock lock : locks) {
                lock.unlock();
            }
        }

    }
Finds and returns the first matching (including from nested tags) tag
(which is assignable to the given tag class). <br>
<br>

<pre>
<code>
Html html = new Html(null) {{
new Head(this) {{
new TitleTag(this){{
new NoTag(this, "some title");
}};
}};
new Body(this, new Id("one")) {{
new Div(this);
}};
}};

TitleTag titleTag = TagRepository.findOneTagAssignableToTagClass(TitleTag.class, html);

System.out.println(titleTag.getTagName());
System.out.println(titleTag.toHtmlString());

//prints

title
&lt;title&gt;some title&lt;/title&gt;

</code>
</pre>

@param parallel
true to internally use parallel stream. If true it
will split the finding task to different batches and
will execute the batches in different threads in
parallel consuming all CPUs. It will perform faster
in finding from extremely large number of tags but at
the same time it will less efficient in finding from
small number of tags.
@param tagClass
the class of the tag.
@return the first matching tag which is assignable to the given tag
class.
@throws NullValueException
if the {@code tagClass} is null
@since 3.0.0
@author WFF