Use takeWhile in AlphaBeta