Slightly improve code making use of element factories retrieved from an element
We can use is_some_and(...)
instead of map_or(false, ...)
.
Also in a few places the factory was retrieved multiple times, one time
with unwrapping and another time with handling the None
case
correctly. Instead of unwrapping, move code to handle the None
case.