import { TreeNode } from './BinaryTree' ; param { TreeNode } tree1 param { TreeNode } tree2 return { boolean } function HasSubTree ( tree1 , tree2 ) { if ( tree1 === null && tree2 === null ) return true ; if ( tree1 === null || tree2 === null ) return false ; if ( tree1 !== null && tree2 !== null ) { if ( tree1 . val === tree2 . val ) { return HasSubTreeHelper ( tree1 , tree2 ) || HasSubTree ( tree1 . left , tree2 ) || HasSubTree ( tree1 . right , tree2 ) ; } } return HasSubTree ( tree1 . left , tree2 ) || HasSubTree ( tree1 . right , tree2 ) ; } param { TreeNode } tree1 param { TreeNode } tree2 return { boolean } function HasSubTreeHelper ( tree1 , tree2 ) { if ( ! tree1 && ! tree2 ) return true ; if ( ! tree1 || ! tree2 ) return false ; if ( tree1 . val === tree2 . val ) { return HasSubTreeHelper ( tree1 . left , tree2 . left ) && HasSubTreeHelper ( tree1 . right , tree2 . right ) ; } return false ; } export { HasSubTree } ;