How to append bones to a list in a branching manner
Use recursion

import bpy


def walk_bones(bone):
    yield(bone)
    for b in bone.children:
        yield from walk_bones(b)

ob = bpy.context.object
arm = ob.data
rootbones = [b for b in arm.bones if not b.parent]

for rb in rootbones:
    for b in walk_bones(rb):
        print(b.name)


Adjusting slightly to 

def walk_bones(bone, level=0, sp="  "):
    yield(f"{sp * level}{bone.name}")
    for b in bone.children:
        yield from walk_bones(b, level + 1)


Can print out the hierarchy, as an example the rigify shark meta-rig 

spine
  spine.001
    spine.002
      spine.003
        spine.008
          spine.004
            spine.005
              spine.006
                spine.007
                  eye.L
                  eye.R
                  jaw.master
                    jaw
                      jaw.001
                    jaw.002.L
                      jaw.003.L
                    jaw.002.R
                      jaw.003.R
              shoulder.L
                side_fin.L
                  side_fin.L.001
              shoulder.R
                side_fin.R
                  side_fin.R.001
            top_fin
              top_fin.001
          chest_fin.Bot.L
          chest_fin.Bot.R
    mid_fin.Top
    mid_fin.Bot
  back_fin.T.Bk
    back_fin.T.001.Bk
      back_fin.T.002.Bk
  back_fin.B.Bk
    back_fin.B.001.Bk