Fix filtering items in the contents treeview
When filtering the items in the contents panel, we start iterating over
them using rootIndex() to get all the children, don't do the same loop
for each and every item, one go is enough.
Also only use a regular expression if the regularExpression option is
enabled, otherwise just use string operations, the latter is always
faster. With this change, both regex and non-regex search are faster.
BUG: 421469