Count Non Leaf Nodes Leetcode Solutions Python