1from ete3 import Tree
2# Loads 3 independent trees
3t1 = Tree('(A,(B,C));')
4t2 = Tree('((D,E), (F,G));')
5t3 = Tree('(H, ((I,J), (K,L)));')
6print "Tree1:", t1
7#            /-A
8#  ---------|
9#           |          /-B
10#            \--------|
11#                      \-C
12print "Tree2:", t2
13#                      /-D
14#            /--------|
15#           |          \-E
16#  ---------|
17#           |          /-F
18#            \--------|
19#                      \-G
20print "Tree3:", t3
21#            /-H
22#           |
23#  ---------|                    /-I
24#           |          /--------|
25#           |         |          \-J
26#            \--------|
27#                     |          /-K
28#                      \--------|
29#                                \-L
30# Locates a terminal node in the first tree
31A = t1.search_nodes(name='A')[0]
32# and adds the two other trees as children.
33A.add_child(t2)
34A.add_child(t3)
35print "Resulting concatenated tree:", t1
36#                                          /-D
37#                                /--------|
38#                               |          \-E
39#                      /--------|
40#                     |         |          /-F
41#                     |          \--------|
42#            /--------|                    \-G
43#           |         |
44#           |         |          /-H
45#           |         |         |
46#           |          \--------|                    /-I
47#           |                   |          /--------|
48#  ---------|                   |         |          \-J
49#           |                    \--------|
50#           |                             |          /-K
51#           |                              \--------|
52#           |                                        \-L
53#           |
54#           |          /-B
55#            \--------|
56#                      \-C
57# But remember!!!You should never do things like:
58#
59# A.add_child(t1)
60#
61