If this is a leaf node and path to this node has maximum sum so far , then make this node target_leaf
if ( Node -> left == NULL && Node -> right == NULL ) { if ( curr_sum > * max_sum_ref ) { * max_sum_ref = curr_sum ; * target_leaf_ref = Node ; } }