made collect matching children utility method more generic

- so it can potentially be used elsewhere