static int height(TreeNode node, Map<TreeNode, Integer>map) {
    	if (node==null)
    		return 0;
        if (map.containsKey(node))
            return map.get(node);
        int h=Math.max(node.left==null?0:height(node.left,map), node.right==null?0:height(node.right,map))+1;
        map.put(node,h);
        return h;
    }