Remove redundant match case in recursive function