Solution for Assignment 1 (recursive approach to create the custom topology)