function filterAll(
	items = new List(),
	query = '',
	{ nameAttr = 'name', onMatch = noop } = {},
	currentPosition = 'root',
) {
	const result = new List();

	if (query) {
		return items.reduce((acc, item) => {
			const name = item.get(nameAttr, '');
			const children = item.get('children', null);
			let results = acc;
			if (name.toLowerCase().includes(query.toLowerCase())) {
				onMatch(item);
				results = acc.push(item.set('currentPosition', currentPosition));
			}
			if (children) {
				results = results.concat(
					filterAll(children, query, { nameAttr }, `${currentPosition} > ${name}`),
				);
			}
			return results;
		}, result);
	}

	return result;
}
/**
 * apply query on every elements, return them on a single list,
 * @return item in items found with the id
 * @param {Object} options {query, items, idAttr }
 */
apply query on every elements, return them on a single list,
@return item in items found with the id
@param {Object} options {query, items, idAttr }
apply query on every elements return them on a single list @return item in items found with the id @param { Object } options { query items idAttr }
function filterAll(
	items = new List(),
	query = '',
	{ nameAttr = 'name', onMatch = noop } = {},
	currentPosition = 'root',
) {
	const result = new List();
	if (query) {
		return items.reduce((acc, item) => {
			const name = item.get(nameAttr, '');
			const children = item.get('children', null);
			let results = acc;
			if (name.toLowerCase().includes(query.toLowerCase())) {
				onMatch(item);
				results = acc.push(item.set('currentPosition', currentPosition));
			}
			if (children) {
				results = results.concat(
					filterAll(children, query, { nameAttr }, `${currentPosition} > ${name}`),
				);
			}
			return results;
		}, result);
	}
	return result;
}
function filterAll ( items = new List ( ) , query = '' , { nameAttr = 'name' , onMatch = noop } = { } , currentPosition = 'root' , ) { const result = new List ( ) ; if ( query ) { return items . reduce ( ( acc , item ) => { const name = item . get ( nameAttr , '' ) ; const children = item . get ( 'children' , null ) ; let results = acc ; if ( name . toLowerCase ( ) . includes ( query . toLowerCase ( ) ) ) { onMatch ( item ) ; results = acc . push ( item . set ( 'currentPosition' , currentPosition ) ) ; } if ( children ) { results = results . concat ( filterAll ( children , query , { nameAttr } , ` ${ currentPosition } ${ name } ` ) , ) ; } return results ; } , result ) ; } return result ; }
apply query on every elements, return them on a single list,
 @return item in items found with the id
 @param {Object} options {query, items, idAttr }
apply query on every elements return them on a single list @return item in items found with the id @param { Object } options { query items idAttr }