C#: Forech line in a branch in a tree

It is a structure of several lines. I made a tree, where every branch contains the lines that are Connected by the same point. I want to find this node for each branch to Call it the centernode for the branch.
Thus, I want to find the end and startpoint for every line in a branch. How could I do this? how do i reffere to every item in a branch ??

first select tree access on input
then in the editor if you type y. the intellisense will show that you have access to branches now.
now you can you something like this

foreach (int i=0; i<y.BranchCount; i++){
    foreach (object obj in y.Branch(i)){
        // do something here;

exact code not tested but you get the idea

but would you rather use Curve instead of Object if the tree contains curves in each branch?

I do prefer for-loops, since it allows me to offset much easier. But sure, when using a foreach loop replace the type ‘object’ with ‘Curve’ when using curves:

for (int i = 0; i < tree.BranchCount; i++)
      for (int j = 1; j < tree.Branch(i); j++)
          var myItemA = tree.Branch(i)[j-1];
          var myItemB = tree.Branch(i)[j];