How to get the structure:

the original structures
-------------------------

A1 A2
| |
B R
------|------- ------|-----
| | | |
C R E F
|
--------
| |
E F

The table organization is:
father son
A1 B
B C
B R
R E
R F
A2 R

and i would like to obtain the structure only in a record:
A1 B C R E F
A2 R E F

and when i select A1 i will obtain the structure of A1
A1 B
B C
B R
R E
R F

and when i select A2 i will obtain the structure of A2
A2 R
R E
R F

Thanks.