I have table with tree data as in this. @Branko Dimitrijevic gave a great answer. But I have other table with foreign key on table with tree data. In my case other table:
CREATE TABLE TT(
tt_id SERIALPRIMARY KEY,
tt_value VARCHAR(50),
t1_id int REFERENCES t1(id)
);
How copy branch with tree data and data in other table?