Managed to get a recursive aproach.