You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: process_invitation_concern.rb
    path of file: ./repos/coursemology2/app/services/concerns/instance/user_invitation_service
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# This concern deals with the creation of user invitations.
class Instance::UserInvitationService; end

module Instance::UserInvitationService::ProcessInvitationConcern
  extend ActiveSupport::Autoload

  private

  # Processes the invites of the given users into the instance.
  #
  # @param [Array<Hash{Symbol=>String}>] users A mutable array of users to add.
  #   Each hash must have three attributes:
  #     the +:name+,
  #     the +:email+ of
    
  def find_existing_users(email_addresses)
    found_users = User.with_email_addresses(email_addresses)

    found_users.each.flat_map do |user|
      user.emails.map { |user_email| [user_email.email, user] }
    end.to_h
  end

  # Adds existing users to the instance.
  #
  # @param [Array<Hash>] users The user descriptions to add to the instance.
  # @return [Array(Array<InstanceUser>, Array<InstanceUser>)]
  #   A tuple containing the list of users who were newly enrolled
  #   and already enrolled.
  def add_existing_users(users)
    all_instance_users = @current_instance.instance_users.to_h { |iu| [iu.user_id, iu] }
    existing_instance_users = []
    new_instance_users = []
    users.each do |user|
      instance_user = all_instance_users[user[:user].id]
      if instance_user
        existing_instance_users << instance_user
      else
        new_instance_users <<
          @current_instance.instance_users.build(user: user[:user], role: user[:role])
      end
    end

    [new_instance_users, existing_instance_users]
  end