Two-way Palindromic Closure Generator Introduction
A palindromic closure of an input string is the shortest palindrome that can be constructed out of the input string where the final palindrome starts with the input string.
For this challenge, we will consider a two-way palindromic closure such that

Left Palindromic Closure of an input string is the shortest palindrome possible that starts with the input string.
Right Palindromic Closure of an input string is the shortest palindrome possible that ends with the input string.
Two-way Palindromic Closure of an input string is the shorter of either of Left or Right Palindromic Closure of the input string.

Task
Your task is simple. Given a string (consisting only of printable ASCII, new lines and white spaces), output the two-way palindromic closure of that string. In case of tie, either of the left or right palindromic closures are valid output.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument, and either printing the result to STDOUT (or closest alternative) or returning it as a string.
You can assume that the input will never be an empty string.
Few examples:
&lt;Input&gt;   -&gt; &lt;Output&gt;
&quot;abcdef&quot;  -&gt; &quot;abcdefedcba&quot;  (or &quot;fedcbabcdef&quot;)
&quot;abcba&quot;   -&gt; &quot;abcba&quot;
&quot;abcb&quot;    -&gt; &quot;abcba&quot;
&quot;cbca&quot;    -&gt; &quot;acbca&quot;


Initial Idea credit goes to VisualMelon, final idea with help from Martin and Zgarb
The terms palindromic closure, left-pallindromic closure and right-palindromic closure were first used and defined by this paper.
Pyth, 22 19

hfq_TTsm,+z_d+_dzyz


Try it online. 

Explanation

The two-way palindromic closure is either of the form AX or XA, where X is the input string and A is a substring of X. I actually has to be a contiguous substring of X, a prefix for the one form, a suffix for the other form. But I don't care about these defails. A substring (contiguous or not) is all I need in Pyth. 

                        Implicit: z = raw_input() // Read a string
                 yz     A list with all substrings (contiguous or not) of z
       m                For each of these substrings d, build
        ,                  a pair of two strings:
         +z_d              ( z + inveres(d) ,
             +_dz            inverse(d) + z )
      s                 Sum (put all created pairs into a list)
 fq_TT                  filter elements T, where inverse(T) == T (Palindrom)
h                          Take the first element


Edit

The old version ordered the the strings after filtering by length .olN.... Just realized, that y returns the substrings ordered by length. So these palindromes are already sorted.