Print all full nodes in a Binary Tree | utility that allocates a newNode with the given key ; Traverses given tree in Inorder fashion and prints all nodes that have both children as non - empty . ; Driver Code
class newNode : NEW_LINE INDENT def __init__ ( self , key ) : NEW_LINE INDENT self . data = key NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def findFullNode ( root ) : NEW_LINE INDENT if ( root != None ) : NEW_LINE INDENT findFullNode ( root . left ) NEW_LINE if ( root . left != None and root . right != None ) : NEW_LINE INDENT print ( root . data , end = " ▁ " ) NEW_LINE DEDENT findFullNode ( root . right ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = newNode ( 1 ) NEW_LINE root . left = newNode ( 2 ) NEW_LINE root . right = newNode ( 3 ) NEW_LINE root . left . left = newNode ( 4 ) NEW_LINE root . right . left = newNode ( 5 ) NEW_LINE root . right . right = newNode ( 6 ) NEW_LINE root . right . left . right = newNode ( 7 ) NEW_LINE root . right . right . right = newNode ( 8 ) NEW_LINE root . right . left . right . left = newNode ( 9 ) NEW_LINE findFullNode ( root ) NEW_LINE DEDENT