@rlamy unnecessary_permutation should be made an empty list only on the initial call