Advanced recursive algorithm to place values.