write method which return size of subtree