added dummy root to avoid nullptr check in flatten