ENH: detect if it is leaf node in run time