Full node structure for Link-Cut tree with path aggregates:
class Node:
// Tree structure
left, right: Node
parent: Node
// Value and aggregates
value: int
subtreeSum: int // or min, max, etc.
subtreeSize: int
// Lazy propagation
lazy: int // pending add
reversed: bool // pending reversal
function isRoot()
// Root of auxiliary tree: parent is null or parent doesn't point back
return parent is null or (parent.left != this and parent.right != this)
The isRoot check is subtle: a node can have a parent (path-parent) but still be root of its auxiliary tree.