There are probably a few different ways to do this in SSIS, and each will probably work, but I will start with the questions.
Where is your source data coming from?
What do you mean by related company? Is that a Parent Company?
Let's take a scenario that your Source is in SQL.
I would make sure that I have a unique integer identity field for the source. The reason for this is that I can query the data back and get record Ids if necessary. I would also add columns called ContactId (uniqueidentifier), and ParentAccountId (uniqueidentifer) - If that is what you meant by related company. Think of it as a staging table.
I am basing the following on using KingswaySoft SSIS tool. Each step below is basically a different Control Flow.
Some of the steps below are optional, and I explain at the end in the Notes.
Step 1 - Import All Contacts, and add the unique integer id that we created in the importsequencenumber field. You will need to apply different logic if you have multiple contact or duplicate contacts, by checking the contact exists based on a unique field such as email address.
Step 2 (Optional) - Retrieve the Guids of all contacts and store them back to your source. Use the lookup control and query the FilteredContacts view in the CRM database to get the Ids. As mentioned in the previous step, this can be by importsequencenumber or email address (or another unique field).
Step 3 - Import all the parent accounts (records that do not have related companies).
Step 4 (Optional)- Retrieve the Guid of all parent accounts and store them back to the source. Use the lookup control and query the FilteredAccounts view in the CRM database to get the Ids. In this case this can be by importsequencenumber or account name.
Step 5 - Import all the accounts that have a Guid for the related account. The ones that were not yet imported. Make sure that you enter the parent account id here.
Step 6 (Optional) - Retrieve all the account Guid of the child accounts. Use the lookup control and query the FilteredAccounts view in the CRM database to get the Ids. In this case this can be by importsequencenumber or account name.
Step 7 - Associate the parents with the children. Update the primary contact id field (primarycontactid) in the account entity.
=> This can also be done in the previous stages...
Notes:
--> If you have multiple depths of parent accounts, the logic will have to get modified, and Steps 3-6 will have to be run on each level of accounts.
--> The retrieval methods are not required (optional), as you can do the match (lookup) within the import/creation process, but will just make it for an easy way to stage your data and check it before importing it in each stage.
As mentioned, this is one way of implementing this. Although long, easy on complexity. There are shorter way to do this, but will be more complex.
If your data source already has GUIDs for accounts and contacts, this can become much easier, as you will not have to retrieve those values back into your datasource.
Not having seen your data, this is my recommendation. You might be able to get this to work with the Data Import wizard as well, which will do some matching. Maybe with 2 imports, but since you asked the SSIS route, this is not a bad way.