optimization of upadte energy using unique and sorted insertion as in "del_path" function
new shorcut insert_all_unique_sorted for insert_unique_sorted use on lists