You can group 2 companies by making one company as a member of another company.
1. Open the Organisation record which needs to be grouped.
2. Click on Edit
3. Look for the field named Member Of
and click on the magnifying glass icon besides the field.
4. Select the Organisation you wish to group with.
Once the Organisation is grouped, you can check the Organisation Hierarchy by following these steps
1. Open the Organisation record which has a member company
2. Click on the three dots
on the right top
3. Click on Organization Hierarchy