def traverse(self, fn=None, specs=None, full_breadth=True):
        """Traverses object returning matching items

        Traverses the set of children of the object, collecting the
        all objects matching the defined specs. Each object can be
        processed with the supplied function.

        Args:
            fn (function, optional): Function applied to matched objects
            specs: List of specs to match
                Specs must be types, functions or type[.group][.label]
                specs to select objects to return, by default applies
                to all objects.
            full_breadth: Whether to traverse all objects
                Whether to traverse the full set of objects on each
                container or only the first.

        Returns:
            list: List of objects that matched
        """
        if fn is None:
            fn = lambda x: x
        if specs is not None and not isinstance(specs, (list, set, tuple)):
            specs = [specs]
        accumulator = []
        matches = specs is None
        if not matches:
            for spec in specs:
                matches = self.matches(spec)
                if matches: break
        if matches:
            accumulator.append(fn(self))

        # Assumes composite objects are iterables
        if self._deep_indexable:
            for el in self:
                if el is None:
                    continue
                accumulator += el.traverse(fn, specs, full_breadth)
                if not full_breadth: break
        return accumulator
def traverse ( self , fn = None , specs = None , full_breadth = True ) : if fn is None : fn = lambda x : x if specs is not None and not isinstance ( specs , ( list , set , tuple ) ) : specs = [ specs ] accumulator = [ ] matches = specs is None if not matches : for spec in specs : matches = self . matches ( spec ) if matches : break if matches : accumulator . append ( fn ( self ) ) if self . _deep_indexable : for el in self : if el is None : continue accumulator += el . traverse ( fn , specs , full_breadth ) if not full_breadth : break return accumulator
Traverses object returning matching items

        Traverses the set of children of the object, collecting the
        all objects matching the defined specs. Each object can be
        processed with the supplied function.

        Args:
            fn (function, optional): Function applied to matched objects
            specs: List of specs to match
                Specs must be types, functions or type[.group][.label]
                specs to select objects to return, by default applies
                to all objects.
            full_breadth: Whether to traverse all objects
                Whether to traverse the full set of objects on each
                container or only the first.

        Returns:
            list: List of objects that matched