In New South Wales, the Liberal party has won by-elections in the Sydney seats of Epping and Hornsby, while a "teal" independent has wrestled control in Pittwater.