Given a tree where each node has an integer value, for each node you may choose EITHER the current node's value OR the values of its children nodes — but not both (i.e., if you select a node, you cannot select its parent or its direct children). Return the maximum…