Best First Search Algorithm Python Code