Implemented group recursion to traverse through nested groups.