Help for this page
$tree = <>; chop($tree); while ($tree=~s/\(?([A-Z])([A-Z])\)?/\1/) { print $tree; print "\n"; }
(A(BD)(EF)) (AB(EF)) A(EF)) AE) A