added Tree.invert method