Port SweepAndPruneAlgorithm with a test

Signed-off-by: Aleksi Sapon <QcTechs@gmail.com>