Added recursive OO code for build_pyramid