Make count_ops() work with logic operations by creating a binary tree. Bug was that Logic functions are not the instance of sympy.core.expr.Expr due to which logic operation were actually skipping to "else" case.
Fixes #7010