Added recursive path creation function