Parsing a NがNのNは construction?


I was reading the following example sentence:

> お父さんが医者の学生は三人います。

My first instinct was to parse this as:

> {お父さんが[医者の学生]}は三人います。

But this led to a slightly non-sensical translation along the lines of 'There
are three fathers who are students of doctors.'

Since the true translation was 'There are three students whose fathers are
doctors', I assume the sentence must be parsed as:

> {[お父さんが医者]の学生}は三人います。

Does this mean I am wrong to automatically separate NのN constructions as
having a 'priority' over other types of constructions (such as NがN)? Is it
best to assume no 'stronger' relationship and to just parse a sentence into
whatever makes the most contextual sense?

Or is it parsed as the second way because of the relative clause, thus making
this NのN equivalent to NがN to make:

> {[お父さんが医者が]学生}は三人います。

