well the first thing to do is see if you need to verify/enchant.... so check for the level 3 you require for the upgrade.
if less than three skip the rest and reject......
but if three (or more for lazy way,) you need to figure out everything it holds so>>>>
the following will assume no over enchantments will exist and if it finds an over enchantment this LAZY WAY will set that enchantment to the maximum. this method is already very long and complimented so this assumption will give you more hair pulling before you decide to kill yourself due to how complicated it is (jk on kill yourself but really, redstone is very simple) so , on to it
there was a list of enchantments listed by what they enchant.... it was down voted by at least three people with their heads so far up their "where the sun don't shine" that you should immediately ignore everything they say.... too bad we don't have a complete list of them.... on to the list.
that list helps to limit what to check for so on the list of the item in question, the range is 32 - 35 but you already know unbreaking so don't have to check for that.
after each check (32, 33, and 35) you will need to save the value returned... rs latch for each level and each enchantment (don't forget an rs latch for level zero of each) then simply set the correct latch for each three
now you have over a dozen rs latches but only three of them are set. a command block tree can select the correct /give command for giving your upgraded tool. to allow multiple overclocked enchantments would be easier if there is a way to pass a number to the /give command but i doubt that is possible so while this lazy way has only 48 possible /give commands if you were trying to jump increase armor the command tree would be 80,000 - 200,000 depending on what enchantment you were increasing
that all said, I have a less than automatic way to do this but WAY WAY simpler
it is different from you intention so i will place in a separate answer