Added flattenSelf to replace a ptree with its child.