code: public static function merge_owners(SS_List $groups, SS_List $members)
      {
          $contentReviewOwners = new ArrayList();
  
          if ($groups->count()) {
              $groupIDs = [];
  
              foreach ($groups as $group) {
                  $familyIDs = $group->collateFamilyIDs();
  
                  if (is_array($familyIDs)) {
                      $groupIDs = array_merge($groupIDs, array_values($familyIDs));
                  }
              }
  
              array_unique($groupIDs);
  
              if (count($groupIDs)) {
                  $groupMembers = DataObject::get(Member::class)
                      ->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")
                      ->leftJoin("Group_Members", "\"Member\".\"ID\" = \"Group_Members\".\"MemberID\"")
                      /** @skipUpgrade */
                      ->leftJoin('Group', "\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"");
  
                  $contentReviewOwners->merge($groupMembers);
              }
          }
  
          $contentReviewOwners->merge($members);
          $contentReviewOwners->removeDuplicates();
  
          return $contentReviewOwners;
      }
docs: Takes a list of groups and members and return a list of unique member.
  
  @param SS_List $groups
  @param SS_List $members
  
  @return ArrayList