First version of Costanza's multi level algorithm.