keep_branches function

Keep only branches specified by node numbers