If the leaf node is encountered , then the path is printed if the size of the path vector is greater than 0
if ( root . left == null && root . right == null ) { if ( flag == 1 ) { ans = 1 ; document . write ( " " ) ; for ( var i = 0 ; i < path . length ; i ++ ) { document . write ( path [ i ] + " " ) ; } document . write ( root . data + " " ) ; } return ; }