Refactor the subdocument searching into its own method for reusability.