No, that analysis can hardly be defended in terms of X-bar theory. The analysis shows D'2 lower in the structure than D2, and DP2 as a sister of the head D2. A projection of a head can never appear lower in the structure than the head, nor can it appear as a sister of the head, but rather it must appear above the head.
There are a couple of points that should be kept in mind when analyzing the structure of NPs. Perhaps the most controversial issue concerns whether noun phrases are NPs or DPs. The question assumes DPs, but that is a controversial assumption. A number of frameworks (Head-Driven Phrase Structure Grammar, Construction Grammar, Categorial Grammar, Meaning-Text Theory, etc.) assume NPs, not DPs. Hence one could reject the analysis shown based on this controversy alone. For arguments for and against DPs, see this article: https://en.wikipedia.org/wiki/Determiner_phrase.
My personal view is that the traditional NP analysis of noun phrases is more defensible, and I think that the example illustrates a difficulty with the DP analysis in general. Most discussions of the DP-hypothesis remain with single determiners; they do not explore stacked possessives like in the example in the question. Consider the following examples in this regard:
1 a. Ali's father
b. Ali's father's mother
If the 's is the head of the phrase Ali's father in (1a), then we should assume that the first 's is also the head of Ali's father's mother (not the second 's) in (1b). But intuitively that does does not seem right.
I think the traditional NP analysis is more consistent with such data, and in fact there is an empirical argument that supports the NP analysis, i.e proform substitution:
a. Ali 's father
b. his father
a. Ali's father's mother
b. his father's mother
c. his mother
Proform substitution is a test for constituent structure that is widely employed in beginning textbooks for syntax. If a definite proform can be substituted in for a string of words, then that string is likely a constituent. In this case then, his can be substituted in for Ali's, indicating that Ali's is a constituent. Similarly, his can be substituted in for Ali's father's, indicating that Ali's father's is also a constituent.
Consider these facts with respect to the first DP tree in the question. That tree shows Ali's as a non-constituent, hence my conclusion is that the first tree in the question is also incorrect. The traditional NP-analysis, which would show Ali's as a constituent, is more defensible.
Concerning the second tree in the question, I think the constituent structure shown would be accurate for the NP Ali's father's mother, because the combination Ali's father's would receive the status of a constituent. But the labeling in that tree is all off.