Yes I am not concerned about direction, I have built a list of edges of the cubes, but exactly the problem is how to place new cubes around them, in 2d this seems relatively simple, but as soon as you add a 3rd dimension, it becomes a whole new set of problems and I am just totally lost as to where to go now.

My original thought is to order the list of cubes/xyz into lowers->highest, then run through them building new cubes to the left of, but then the issue is not all cubes are touching, so there would be gaps left between multiple cubes, it must also take into consideration the positions of other cubes on that directional plane.