Remove useless leaf nodes