Check for both imported and 'as' names in insertImport(), return false if no new import statements were inserted (PY-14439)

(cherry picked from commit 2234db8098b3d436a5ae3b249ae46fc96d653110)
fix issues from IDEA-COMMUNITY-CR-987

(cherry picked from commit 911b2a36e58714ab64bc070d2c4b5f2d6c77e070)
fix bug for not 2d arrays and remove busyTable

(cherry picked from commit afcc461543774e5bab83028dd80f9dd8ff89c17b)
Fix condition for Python 2.4 (PY-14437).

(cherry picked from commit 5755bc577c1970a7b7133d6ccbf2c2f9afeeba6f)
Don't need to encode format (PY-14438).

(cherry picked from commit 6fa2f131113f2080c4ee1f31f9b59d3594694e0f)