Optimize removing node from frontier