# File lib/rhc/commands/member.rb, line 373
      def search_team_members(members, names)
        r = []
        team_members = members.select(&:team?)
        names.each do |name|

          team_for_name = nil
          suggestions = nil

          if (exact_matches = team_members.select{|team| team.name == name }).present?
            if exact_matches.length == 1
              team_for_name = exact_matches.first
            else
              raise RHC::MemberNotFoundException.new("There is more than one member team named '#{name}'. " +
                "Please use the --ids flag and specify the exact id of the team you want to manage.")
            end

          elsif (case_insensitive_matches = team_members.select{|team| team.name =~ /^#{Regexp.escape(name)}$/i}).present?
            if case_insensitive_matches.length == 1
              team_for_name = case_insensitive_matches.first
            else
              suggestions = case_insensitive_matches
            end

          else
            suggestions = team_members.select{|t| t.name =~ /#{Regexp.escape(name)}/i}
          end

          if team_for_name
            r << team_for_name
          elsif suggestions.present?
            raise RHC::MemberNotFoundException.new("No member team found with the name '#{name}'. " +
              "Did you mean one of the following?\n#{suggestions[0..50].map(&:name).join(", ")}")
          else
            raise RHC::MemberNotFoundException.new("No member team found with the name '#{name}'.")
          end

        end
        r.flatten
      end