As @cpast noted, this would depend on the specific country you have in mind and “parliamentary democracy, unitary state” is not enough to determine which one you mean. Basically, those are simply descriptive categories that are convenient to describe a set of broadly similar political systems but each of them have slightly different rules and conventions (and sometimes widely different electoral and party systems). Still, I think it's possible to say a bit more about your questions that should be valid for many parliamentary democracies.
Constitutions typically do not have any strict rules on who should become head of government or who can be a cabinet member but rather procedural rules giving a president or monarch the power to pick someone to form a government. And, while an exact 50/50 split is not common, in many parliamentary democracies lack of absolute majority for a single party is the rule rather than an exception. So even when leaders are important figures, they do not technically win elections or a majority, political parties do and they have to form coalitions.
Often, who the next head of government should be is obvious and the head of state has no actual discretion but formally the rule is still “the head of state picks a prime minister” or something like that, with no legal constraints whatsoever. Similarly, in many countries, it is not forbidden (and sometimes not unusual) for cabinet ministers not to be members of parliament at the time of their nomination.
At the end of the day, the key test is that the new government must be elected/confirmed by the parliament. Picking the leader of party A over party B would not bring much if party B, C, and D are bent on governing together. Conversely, if the parties can't agree with each other and nobody is in a position to gather an absolute majority in parliament, forming a government can prove impossible even with a distribution like 35/25/20/20.
And doing something crazy like picking the leader of a small party who then selects cabinet members outside the usual pool of candidates would create a major crisis and simply does not happen. Even if it would happen, there would be no new government and the would-be prime minister would hold no actual power, unless and until the parliament can be brought in line.
If we look at actual cabinet formation examples, when there is a clear majority, the process can be quick and mostly transparent but in some cases it is more difficult, which helps imagining how things could work in your scenario. For example, during the 2010 Dutch cabinet formation, several politicians were named to explore different coalitions before a solution could be found and some of them did not come from the party that won the most seats in the elections.
You can also find examples of coalitions that do not include the party that has the highest number of seats in parliament and seemingly won the elections at all. In fact, in Belgium, the New Flemish Alliance (NVA) has been the largest party by overall number of votes in the last two elections but its leader has never been a cabinet minister, let alone prime minister. After the 2010 elections, the party wasn't even part of the government coalition. It is currently part of the (federal) majority but the prime minister comes from another (junior) partner in the coalition. Still, the NVA got first dips at forming a coalition every time (concretely, the leader of the party was named informateur) before other options were explored.
In other countries, like Germany, cabinet formation is entirely driven by the parties, and the formal process only starts after some sort of coalition has emerged. Concretely, the two biggest parties invite potential junior partners to discuss a potential coalition and to make their demands. Depending on their strategies, smaller parties can also decide to talk to only one or both large parties or perhaps none at all.
So in your example, the head of state could go with the leader of the party that got the most votes (even if the number of seats ended up being equal) or with the leader of the party that has the best chance to find a coalition or possibly wait a bit to see who comes out on top. Or he or she could start with the largest party and get more creative if that fails.
Because there is some flexibility in this process and the parliament is ultimately free to decide to enforce the local conventions or to disregard the traditions, equality between the two top parties would not necessarily make it impossible to find a coalition.
By contrast, what does gripe a parliamentary system are parties that eat up votes from other parties (or the main left/right blocks of parties) but are reluctant or unable to participate in any coalition (in a way, that's the case for the NVA in Belgium, Die Linke in Germany, etc.) even when election results are clear-cut.
Crucially, coalition-building, not raw seat numbers, is the real constraint. When simple conventions or obvious alliances are not enough to find a majority, it's not meaningful to think of cabinet formation arithmetically as a game between “party A” and “party B”, the outcome depends entirely on the specific context. So if extraordinary circumstances means that political parties and/or members of parliament are willing to go with unconventional ministers, anything is possible. But nobody can force them to merely because no one party has won a clear majority.
Incidentally, in parliamentary democracies, “leader” or “candidate” are informal positions, their names are not on the ballot and all the power and influence they hold stems from their control of their own political party. You can find examples of declared candidates stepping back between the election and the actual cabinet formation (e.g. Gerhard Schröder in Germany after he lost his 2005 bid for reelection, even if his party did participate in the next cabinet), prime ministers that weren't the leader of any party or even members of parliament (e.g. Mario Monti of Italy) and of course many many coalitions formed during a legislature, with a new prime minister that hasn't led his party to a general election before being elected by the parliament (Matteo Renzi would be the last example but in Italy very few prime ministers remained in power for the full five-year legislature period and many came to power in-between general elections).
Summary: (Near-)equality between pairs of party is not a problem at all, it just means you need three of them instead of just two. If either A or B can bring C and D together, it will be able to lead the government. On the other hand, if there are rigid blocks like A+C and B+D and none of them has an absolute majority, it might be more difficult to form a cabinet, even if either A or B emerged as a clear winner.