Need ideas about how to select specific part in a soy plant

Hey everyone,
i need ideas about how to select the main stem of a soy plant as you see in the photos i uploaded.
i also need to select separately all the soy beans in the plant and calculate the angle of the first branch.
this need to be automated or semi automated solution for this problems.

i tried modify the photo to black and white and then save as .txt file
after this run a python code on the pixel matrix to select the biggest branch in the planet
and copy the biggest branch to new matrix in new .txt file.
so now i have just the main stem in black and white
and i’m looking for a way to select the this branch and cut it from the original photo.
do you have any ideas how to do it?
or maybe a better solution for my needs.
thanks.

Angle