Even more interesting is that this phenomenon is a product of evolutionary adaptation. Basically, trees that exhibit this botanical phenomenon developed it to make it easier for birds, bats, and animals to reach their flowers for pollination and their fruits for seed dispersal.
So yes, developing flowers and fruits on their stems and trunks is the key to their survival as distinct species.
A great example of a cauliflory tree is this wild fig tree that's quite common in Cordillera's mountains. We spotted this one in Atok, Benguet. Cordilleran words for it: tebbel, tebfel, labay, ballay.