dfs checking balanced tree