The sample shows how to make the visibility of some layers dependent on other layers, which you would need to implement proper "tree" semantics (so that, for example, disabling a parent disables its children).
You can then display hierarchies of OCGs using PDF.OCG.Config.SetOrder():