correct preservation of the tree structure in filter_er_tree method