It is probably a comfort thing, and because of that I wonder if it is better to redirect her onto something else, rather than try to stop it entirely. For example, when you put her to bed you could try a big soft hairy toy, or a doll, or a blanky. Or you could try her with a soft beanie for sleeping and push her hair under it so she can't do it automatically and then have something else there for her to stroke/pull etc.