This can sometimes happen in the mikveh.
As long as you comb your hair and remove knots
prior to immersion, you need not worry about any tangling or knotting that might occur during the immersion itself.
Please let us know if we can be of further assistance.