Branches with grasshopper python

Here’s a simple example:

Also refer to this article,